The net worth chart will respect net worth preferences.

This commit is contained in:
James Cole
2018-08-29 10:57:42 +02:00
parent 10d953f336
commit 59f4ecdaa6
9 changed files with 409 additions and 4 deletions

View File

@@ -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.
*