Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fixed tests and added some more.
James Cole138044fb41a0
diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.phpindex d66f660c1e..794203a057 100644--- a/app/tests/controllers/HomeControllerTest.php+++ b/app/tests/controllers/HomeControllerTest.php@@ -39,6 +39,16 @@ class HomeControllerTest extends TestCase}public function testIndexWithAccount() {++ // mock Account+ $account = $this->mock('Account');+ $account->shouldReceive('setAttribute')->with('transactionList',[]);++ // mock account repository+ $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');+ $accounts->shouldReceive('count')->andReturn(0);+ $accounts->shouldReceive('getByIds')->andReturn([$account]);+// mock:View::shouldReceive('share');View::shouldReceive('make')->with('index')->once()->andReturn(\Mockery::self())@@ -46,21 +56,17 @@ class HomeControllerTest extends TestCase->with('count', 0)->andReturn(Mockery::self())->shouldReceive('with')->once() // another 'with' parameter.- ->with('accounts',[])+ ->with('accounts',[$account])->andReturn(Mockery::self());- Auth::shouldReceive('check')->andReturn(true);- // mock Account- $account = $this->mock('Account');- // mock account repository- $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');- $accounts->shouldReceive('count')->andReturn(0);- $accounts->shouldReceive('getByIds')->andReturn([$account]);++ // mock transaction journal+ $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');+ $tj->shouldReceive('getByAccount')->with($account,10)->andReturn([]);// mock preferences helper:- // mock preference:$pref = $this->mock('Preference');$pref->shouldReceive('getAttribute', 'data')->andReturn([1]);diff --git a/app/tests/controllers/PreferencesControllerTest.php b/app/tests/controllers/PreferencesControllerTest.phpnew file mode 100644index 0000000000..3192e13125--- /dev/null+++ b/app/tests/controllers/PreferencesControllerTest.php@@ -0,0 +1,56 @@+<?php++class PreferencesControllerTest extends TestCase+{+ public function setUp()+ {+ parent::setUp();+ }++ public function testIndex()+ {++ // mock preferences helper:+ $pref = $this->mock('Preference');+ $pref->shouldReceive('getAttribute', 'data')->andReturn([]);++++ // mock view:+ View::shouldReceive('share');+ View::shouldReceive('make')->with('preferences.index')->once()->andReturn(\Mockery::self())+ ->shouldReceive('with')->once()->with('accounts', [])->andReturn(\Mockery::self())+ ->shouldReceive('with')->once()->with('frontpageAccounts', $pref)->andReturn(\Mockery::self());++++ $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');+ $preferences->shouldReceive('get')->with('frontpageAccounts', [])->andReturn($pref);++ // mock account repository:+ $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');+ $accounts->shouldReceive('accounts')->andReturn([]);+ $accounts->shouldReceive('getDefault')->andReturn([]);++ // call+ $this->call('GET', '/preferences');++ // test+ $this->assertResponseOk();+ }++ public function testPostIndex() {+ // mock+ $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');+ $preferences->shouldReceive('set')->with('frontpageAccounts', [1])->andReturn(true);++ // call+ $this->call('POST', '/preferences',['frontpageAccounts' => [1]]);++++ // test+ $this->assertSessionHas('success');+ $this->assertRedirectedToRoute('preferences');+ }+}\ No newline at end of filediff --git a/phpunit.xml b/phpunit.xmlindex 09ad9b1635..e0b7cc582f 100644--- a/phpunit.xml+++ b/phpunit.xml@@ -22,6 +22,7 @@<directory suffix=".php">./app/helpers</directory><exclude><file>./app/controllers/BaseController.php</file>+ <file>./app/controllers/MigrationController.php</file></exclude></whitelist>