mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-09-29 21:11:12 -04:00
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the code style applied by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] ruleset to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started. For more information on customizing the code style applied by Shift, [watch this short video][4]. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://github.com/squizlabs/PHP_CodeSniffer [3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 [4]: https://laravelshift.com/videos/shift-code-style
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Account;
|
|
use App\Models\Client;
|
|
use App\Models\Company;
|
|
use App\Models\Credit;
|
|
use App\Models\CreditInvitation;
|
|
use App\Models\User;
|
|
use App\Utils\Traits\AppSetup;
|
|
use Tests\MockUnitData;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
class CreditBalanceTest extends TestCase
|
|
{
|
|
use MockUnitData;
|
|
use AppSetup;
|
|
|
|
public function setUp() :void
|
|
{
|
|
parent::setUp();
|
|
|
|
Credit::all()->each(function ($credit) {
|
|
$credit->forceDelete();
|
|
});
|
|
|
|
$this->makeTestData();
|
|
|
|
$this->buildCache(true);
|
|
}
|
|
|
|
public function testCreditBalance()
|
|
{
|
|
$credit = Credit::factory()->create([
|
|
'user_id' => $this->user->id,
|
|
'company_id' => $this->company->id,
|
|
'client_id' => $this->client->id,
|
|
'balance' => 10,
|
|
'number' => 'testing-number-01',
|
|
'status_id' => Credit::STATUS_SENT,
|
|
]);
|
|
|
|
$this->assertEquals($this->client->service()->getCreditBalance(), 10);
|
|
}
|
|
|
|
public function testExpiredCreditBalance()
|
|
{
|
|
$credit = Credit::factory()->create([
|
|
'user_id' => $this->user->id,
|
|
'company_id' => $this->company->id,
|
|
'client_id' => $this->client->id,
|
|
'balance' => 10,
|
|
'due_date' => now()->addDays(5),
|
|
'number' => 'testing-number-02',
|
|
'status_id' => Credit::STATUS_SENT,
|
|
]);
|
|
|
|
$this->assertEquals($this->client->service()->getCreditBalance(), 0);
|
|
}
|
|
}
|