Fixed all tests.

This commit is contained in:
James Cole committed 2014-07-15 07:36:01 +02:00
1 parent 09b6c4d982
commit 445de5a1d8
7 files changed
+131 -42

No files matched your search

@@ -13,11 +13,11 @@ class ChartControllerTest extends TestCase
{
// mock preference:
$pref = $this->mock('Preference');
$pref->shouldReceive('getAttribute', 'data')->andReturn('week');
$pref->shouldReceive('getAttribute', 'data')->andReturn('1M');
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// mock toolkit:
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
@@ -73,7 +73,7 @@ class ChartControllerTest extends TestCase
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// mock toolkit:
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
@@ -111,11 +111,11 @@ class ChartControllerTest extends TestCase
// mock preference:
$pref = $this->mock('Preference');
$pref->shouldReceive('getAttribute', 'data')->andReturn('week');
$pref->shouldReceive('getAttribute', 'data')->andReturn('1M');
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// mock toolkit:
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
@@ -153,7 +153,7 @@ class ChartControllerTest extends TestCase
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// call
@@ -183,7 +183,7 @@ class ChartControllerTest extends TestCase
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// call
@@ -213,7 +213,7 @@ class ChartControllerTest extends TestCase
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn($pref);
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// call
@@ -26,10 +26,8 @@ class HomeControllerTest extends TestCase
$accounts->shouldReceive('count')->andReturn(0);
$accounts->shouldReceive('getActiveDefault')->andReturn([]);
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('frontpageAccounts',[])->andReturn(new \Preference)->once();
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn('week');
// call
$this->call('GET', '/');
@@ -73,7 +71,6 @@ class HomeControllerTest extends TestCase
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('frontpageAccounts',[])->andReturn($pref)->once();
$preferences->shouldReceive('get')->with('viewRange', 'week')->once()->andReturn('week');
// call
$this->call('GET', '/');
@@ -0,0 +1,39 @@
<?php
class JsonControllerTest extends TestCase {
public function setUp()
{
parent::setUp();
}
public function testBeneficiaries() {
$obj = new stdClass;
$obj->name = 'Bla bla';
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('getBeneficiaries')->andReturn([$obj]);
$this->call('GET', '/json/beneficiaries');
// test
$this->assertResponseOk();
}
public function testCategories() {
$obj = new stdClass;
$obj->name = 'Bla bla';
// mock category repository:
$categories = $this->mock('Firefly\Storage\Category\CategoryRepositoryInterface');
$categories->shouldReceive('get')->andReturn([$obj]);
$this->call('GET', '/json/categories');
// test
$this->assertResponseOk();
}
}
@@ -14,18 +14,21 @@ class PreferencesControllerTest extends TestCase
$pref = $this->mock('Preference');
$pref->shouldReceive('getAttribute', 'data')->andReturn([]);
$viewPref = $this->mock('Preference');
$viewPref->shouldReceive('getAttribute', 'data')->andReturn('1M');
// 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('viewRange', '1M')->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);
$preferences->shouldReceive('get')->with('viewRange', '1M')->andReturn($viewPref);
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
@@ -39,14 +42,15 @@ class PreferencesControllerTest extends TestCase
$this->assertResponseOk();
}
public function testPostIndex() {
public function testPostIndex()
{
// mock
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('set')->with('frontpageAccounts', [1])->andReturn(true);
$preferences->shouldReceive('set')->with('viewRange', '1M')->andReturn(true);
// call
$this->call('POST', '/preferences',['frontpageAccounts' => [1]]);
$this->call('POST', '/preferences', ['frontpageAccounts' => [1], 'viewRange' => '1M']);
// test
@@ -0,0 +1,25 @@
<?php
class TransactionControllerTest extends TestCase
{
public function testCreateWithdrawal()
{
View::shouldReceive('share');
View::shouldReceive('make')->with('transactions.withdrawal')->andReturn(\Mockery::self())
->shouldReceive('with')->once()
->with('accounts', [])
->andReturn(Mockery::self());
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
// call
$this->call('GET', '/transactions/add/withdrawal');
// test
$this->assertResponseOk();
}
}