mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
The net worth chart will respect net worth preferences.
This commit is contained in:
@@ -264,6 +264,54 @@ class AccountControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
*/
|
||||
public function testStoreLiability(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->first();
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('store')->once()->andReturn($account);
|
||||
$repository->shouldReceive('getOpeningBalanceAmount')->andReturn('10');
|
||||
$repository->shouldReceive('getOpeningBalanceDate')->andReturn('2018-01-01');
|
||||
$currencyRepos->shouldReceive('setUser')->once();
|
||||
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('defaultAsset');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('1');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('BIC');
|
||||
$repository->shouldReceive('getNoteText')->withArgs([Mockery::any()])->andReturn('Hello');
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new liability account #' . random_int(1, 10000),
|
||||
'currency_id' => 1,
|
||||
'type' => 'liability',
|
||||
'active' => 1,
|
||||
'include_net_worth' => 1,
|
||||
'liability_amount' => '10000',
|
||||
'liability_start_date' => '2016-01-01',
|
||||
'liability_type' => 'mortgage',
|
||||
'interest' => '1',
|
||||
'interest_period' => 'daily',
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/accounts', $data, ['Accept' => 'application/json']);
|
||||
$response->assertSee($account->name);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => ['type' => 'accounts', 'links' => true],]);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Name already in use.
|
||||
*
|
||||
|
Reference in New Issue
Block a user