mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
And.. completed the account controller.
This commit is contained in:
@@ -176,12 +176,124 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
public function testStore()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
// an account:
|
||||
$this->be($this->account->user);
|
||||
|
||||
$data = [
|
||||
'name' => 'New test account ' . rand(1, 1000),
|
||||
'what' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'openingBalance' => 20,
|
||||
'openingBalanceDate' => date('Y-m-d'),
|
||||
'openingBalanceCurrency' => 1,
|
||||
'_token' => 'replaceme'
|
||||
];
|
||||
|
||||
// fake validation routine:
|
||||
$request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest');
|
||||
$request->shouldReceive('input')->andReturn('');
|
||||
|
||||
// fake store routine:
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$repository->shouldReceive('store')->andReturn($this->account);
|
||||
|
||||
$this->call('POST', '/accounts/store', $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
}
|
||||
|
||||
public function testStoreAndRedirect()
|
||||
{
|
||||
// an account:
|
||||
$this->be($this->account->user);
|
||||
|
||||
$data = [
|
||||
'name' => 'New test account ' . rand(1, 1000),
|
||||
'what' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'openingBalance' => 20,
|
||||
'openingBalanceDate' => date('Y-m-d'),
|
||||
'openingBalanceCurrency' => 1,
|
||||
'_token' => 'replaceme',
|
||||
'create_another' => 1,
|
||||
];
|
||||
|
||||
// fake validation routine:
|
||||
$request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest');
|
||||
$request->shouldReceive('input')->andReturn('');
|
||||
|
||||
// fake store routine:
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$repository->shouldReceive('store')->andReturn($this->account);
|
||||
|
||||
$this->call('POST', '/accounts/store', $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
|
||||
// an account:
|
||||
$this->be($this->account->user);
|
||||
|
||||
$data = [
|
||||
'name' => 'Edited test account ' . rand(1, 1000),
|
||||
'active' => 1,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'virtualBalance' => 0,
|
||||
'openingBalance' => 25,
|
||||
'openingBalanceDate' => date('Y-m-d'),
|
||||
'openingBalanceCurrency' => 1,
|
||||
'_token' => 'replaceme'
|
||||
];
|
||||
|
||||
// fake validation routine:
|
||||
$request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest');
|
||||
$request->shouldReceive('input')->andReturn('');
|
||||
|
||||
// fake update routine:
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$repository->shouldReceive('update')->andReturn($this->account);
|
||||
|
||||
$this->call('POST', '/accounts/update/' . $this->account->id, $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
}
|
||||
|
||||
public function testUpdateAndRedirect()
|
||||
{
|
||||
|
||||
// an account:
|
||||
$this->be($this->account->user);
|
||||
|
||||
$data = [
|
||||
'name' => 'Edited test account ' . rand(1, 1000),
|
||||
'active' => 1,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'virtualBalance' => 0,
|
||||
'openingBalance' => 25,
|
||||
'openingBalanceDate' => date('Y-m-d'),
|
||||
'openingBalanceCurrency' => 1,
|
||||
'_token' => 'replaceme',
|
||||
'return_to_edit' => 1,
|
||||
];
|
||||
|
||||
// fake validation routine:
|
||||
$request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest');
|
||||
$request->shouldReceive('input')->andReturn('');
|
||||
|
||||
// fake update routine:
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$repository->shouldReceive('update')->andReturn($this->account);
|
||||
|
||||
$this->call('POST', '/accounts/update/' . $this->account->id, $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user