Fixed more tests.

This commit is contained in:
James Cole 2016-12-11 13:16:56 +01:00
parent 43f59a1135
commit 406150620a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 51 additions and 17 deletions

View File

@ -39,15 +39,15 @@ class AccountFormRequest extends Request
public function getAccountData(): array
{
return [
'name' => trim($this->input('name')),
'name' => trim(strval($this->input('name'))),
'active' => intval($this->input('active')) === 1,
'accountType' => $this->input('what'),
'currency_id' => intval($this->input('currency_id')),
'virtualBalance' => round($this->input('virtualBalance'), 2),
'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),
'iban' => trim($this->input('iban')),
'BIC' => trim($this->input('BIC')),
'accountNumber' => trim($this->input('accountNumber')),
'iban' => trim(strval($this->input('iban'))),
'BIC' => trim(strval($this->input('BIC'))),
'accountNumber' => trim(strval($this->input('accountNumber'))),
'accountRole' => $this->input('accountRole'),
'openingBalance' => round($this->input('openingBalance'), 2),
'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')),

View File

@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="true">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>

View File

@ -8,6 +8,8 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
@ -55,10 +57,15 @@ class AccountControllerTest extends TestCase
*/
public function testDestroy()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('find')->withArgs([0])->once()->andReturn(new Account);
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['accounts.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('accounts.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
@ -131,10 +138,23 @@ class AccountControllerTest extends TestCase
*/
public function testStore()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['accounts.create.url' => 'http://localhost']);
$this->be($this->user());
$data = [
'name' => 'new account ' . rand(1000, 9999),
'what' => 'asset',
];
$this->call('post', route('accounts.store', ['asset']), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list should have this new account.
$this->call('GET', route('accounts.index', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
/**
@ -142,9 +162,23 @@ class AccountControllerTest extends TestCase
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['accounts.edit.url' => 'http://localhost']);
$this->be($this->user());
$data = [
'name' => 'updated account ' . rand(1000, 9999),
'active' => 1,
'what' => 'asset',
];
$this->call('post', route('accounts.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list should have this new account.
$this->call('GET', route('accounts.index', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
$this->see($data['name']);
}
}