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 public function getAccountData(): array
{ {
return [ return [
'name' => trim($this->input('name')), 'name' => trim(strval($this->input('name'))),
'active' => intval($this->input('active')) === 1, 'active' => intval($this->input('active')) === 1,
'accountType' => $this->input('what'), 'accountType' => $this->input('what'),
'currency_id' => intval($this->input('currency_id')), 'currency_id' => intval($this->input('currency_id')),
'virtualBalance' => round($this->input('virtualBalance'), 2), 'virtualBalance' => round($this->input('virtualBalance'), 2),
'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')), 'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),
'iban' => trim($this->input('iban')), 'iban' => trim(strval($this->input('iban'))),
'BIC' => trim($this->input('BIC')), 'BIC' => trim(strval($this->input('BIC'))),
'accountNumber' => trim($this->input('accountNumber')), 'accountNumber' => trim(strval($this->input('accountNumber'))),
'accountRole' => $this->input('accountRole'), 'accountRole' => $this->input('accountRole'),
'openingBalance' => round($this->input('openingBalance'), 2), 'openingBalance' => round($this->input('openingBalance'), 2),
'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')), 'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')),

View File

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

View File

@ -8,6 +8,8 @@
* *
* See the LICENSE file for details. * 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() public function testDestroy()
{ {
// Remove the following lines when you implement this test. $repository = $this->mock(AccountRepositoryInterface::class);
$this->markTestIncomplete( $repository->shouldReceive('find')->withArgs([0])->once()->andReturn(new Account);
'This test has not been implemented yet.' $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() public function testStore()
{ {
// Remove the following lines when you implement this test. $this->session(['accounts.create.url' => 'http://localhost']);
$this->markTestIncomplete( $this->be($this->user());
'This test has not been implemented yet.' $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() public function testUpdate()
{ {
// Remove the following lines when you implement this test. $this->session(['accounts.edit.url' => 'http://localhost']);
$this->markTestIncomplete( $this->be($this->user());
'This test has not been implemented yet.' $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']);
} }
} }