2019-09-18 14:43:37 +02:00
|
|
|
<?php
|
2020-09-14 13:11:46 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-09-14 13:11:46 +02:00
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-09-14 13:11:46 +02:00
|
|
|
*/
|
2021-07-02 08:36:14 +02:00
|
|
|
|
2019-09-18 14:43:37 +02:00
|
|
|
namespace Tests\Feature;
|
|
|
|
|
2021-07-02 08:36:14 +02:00
|
|
|
use App\Models\CompanyGateway;
|
2019-09-18 14:43:37 +02:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\Models\Client
|
|
|
|
*/
|
|
|
|
class ClientModelTest extends TestCase
|
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
use MockAccountData;
|
2019-09-18 14:43:37 +02:00
|
|
|
use DatabaseTransactions;
|
|
|
|
|
2022-06-21 12:00:57 +02:00
|
|
|
protected function setUp() :void
|
2019-09-18 14:43:37 +02:00
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
parent::setUp();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->makeTestData();
|
2019-09-18 14:43:37 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
if (config('ninja.testvars.travis') !== false) {
|
2019-10-07 08:43:19 +02:00
|
|
|
$this->markTestSkipped('Skip test for Travis');
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-12-17 11:50:45 +01:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! config('ninja.testvars.stripe')) {
|
2019-12-17 11:50:45 +01:00
|
|
|
$this->markTestSkipped('Skip test no company gateways installed');
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2024-06-18 04:57:15 +02:00
|
|
|
|
|
|
|
if(CompanyGateway::count() == 0)
|
|
|
|
$this->markTestSkipped('Skip test no company gateways installed');
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-09-18 14:43:37 +02:00
|
|
|
|
2021-01-27 02:06:25 +01:00
|
|
|
public function testPaymentMethodsWithCreditsEnforced()
|
2020-03-21 06:37:30 +01:00
|
|
|
{
|
2024-06-18 04:57:15 +02:00
|
|
|
|
2021-01-27 02:06:25 +01:00
|
|
|
$payment_methods = $this->client->service()->getPaymentMethods(40);
|
2019-09-18 14:43:37 +02:00
|
|
|
|
2021-07-02 08:36:14 +02:00
|
|
|
$this->assertGreaterThan(0, CompanyGateway::count());
|
|
|
|
|
2021-01-27 02:06:25 +01:00
|
|
|
$this->assertEquals(1, count($payment_methods));
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-09-18 14:43:37 +02:00
|
|
|
}
|