diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index faac1971d8..34f276999f 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -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')), diff --git a/phpunit.xml b/phpunit.xml index 712e0af587..478d78f2b6 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false"> + stopOnFailure="true"> ./tests diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.php index 3893001d40..4120968399 100644 --- a/tests/acceptance/Controllers/AccountControllerTest.php +++ b/tests/acceptance/Controllers/AccountControllerTest.php @@ -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('