mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 17:33:45 +00:00
Refactor some code for recurrences.
This commit is contained in:
@@ -57,11 +57,9 @@ class AccountControllerTest extends TestCase
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
@@ -84,6 +82,36 @@ class AccountControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
||||
[
|
||||
'id' => 1,
|
||||
'attributes' => [
|
||||
'name' => 'Account'
|
||||
]
|
||||
]);
|
||||
$transformer->shouldReceive('setCurrentScope')->atLeast()->once();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->atLeast()->once()->andReturn([]);
|
||||
|
||||
|
||||
// getAccountType
|
||||
|
||||
$account = $this->getRandomAsset();
|
||||
$response = $this->get(route('api.v1.accounts.show', [$account->id]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
@@ -214,7 +242,7 @@ class AccountControllerTest extends TestCase
|
||||
public function testStoreNotUnique(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -331,7 +359,7 @@ class AccountControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
|
Reference in New Issue
Block a user