Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Update code, work to pass filters. [skip ci]
James Cole61438bf5f1e7
diff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.phpindex ba8b7ae7a6..d596d06367 100644--- a/app/controllers/ChartController.php+++ b/app/controllers/ChartController.php@@ -13,17 +13,19 @@ class ChartController extends BaseControllerprotected $_accounts;protected $_journals;+ protected $_tk;protected $_preferences;/*** @param ARI $accounts* @param TJRI $journals*/- public function __construct(ARI $accounts, TJRI $journals, PHI $preferences)+ public function __construct(ARI $accounts, TJRI $journals, PHI $preferences, tk $toolkit){$this->_accounts = $accounts;$this->_journals = $journals;$this->_preferences = $preferences;+ $this->_tk = $toolkit;}/**@@ -33,7 +35,7 @@ class ChartController extends BaseController*/public function homeAccount($accountId = null){- list($start, $end) = tk::getDateRange();+ list($start, $end) = $this->_tk->getDateRange();$current = clone $start;$return = [];$account = null;@@ -134,7 +136,7 @@ class ChartController extends BaseControllerpublic function homeCategories(){- list($start, $end) = tk::getDateRange();+ list($start, $end) =$this->_tk->getDateRange();$account = null;$result = [];// grab all transaction journals in this period:diff --git a/app/filters.php b/app/filters.phpindex 8c8922959d..27afed181e 100644--- a/app/filters.php+++ b/app/filters.php@@ -5,7 +5,8 @@App::before(function ($request) {if (Auth::check()) {- \Firefly\Helper\Toolkit\Toolkit::getDateRange();+ $toolkit = App::make('\Firefly\Helper\Toolkit\ToolkitInterface');+ $toolkit->getDateRange();}Event::fire('app.before');}diff --git a/app/lib/Firefly/Helper/Toolkit/Toolkit.php b/app/lib/Firefly/Helper/Toolkit/Toolkit.phpindex 1d973cb490..088fb7a6bc 100644--- a/app/lib/Firefly/Helper/Toolkit/Toolkit.php+++ b/app/lib/Firefly/Helper/Toolkit/Toolkit.php@@ -14,7 +14,7 @@ class Toolkit implements ToolkitInterface** $start is always the past, $end is 'now' or at least later.*/- public static function getDateRange()+ public function getDateRange(){$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');$viewRange = $preferences->get('viewRange', '1M');diff --git a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.phpindex 1e36e18a64..edc2a8fef6 100644--- a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php+++ b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php@@ -5,6 +5,6 @@ namespace Firefly\Helper\Toolkit;interface ToolkitInterface{- public static function getDateRange();+ public function getDateRange();}\ No newline at end of filediff --git a/app/tests/controllers/ChartControllerTest.php b/app/tests/controllers/ChartControllerTest.phpindex a4dd9bae9a..ca59ba39dc 100644--- a/app/tests/controllers/ChartControllerTest.php+++ b/app/tests/controllers/ChartControllerTest.php@@ -89,18 +89,26 @@ class ChartControllerTest extends TestCase$start = new \Carbon\Carbon;$end = new \Carbon\Carbon;- $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');- $toolkit->shouldReceive('getDateRange')->andReturn(null);- // mock toolkit:-// $class = $this->getMockClass('Foo', array('baz'));-// $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');-// $toolkit::static ->shouldReceive('getDateRange')->once()->andReturn([$start, $end]);-// // mock transaction journal-// $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');-// $tj->shouldReceive('getByDateRange')->with($start, $end)->andReturn([]);+ // mock toolkit+ $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');+ $toolkit->shouldReceive('getDateRange')->andReturn([$start, $end]);+//+// // mock preference?+// $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');+// $preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);+//+//+// // mock toolkit:+//// $class = $this->getMockClass('Foo', array('baz'));+//// $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');+//// $toolkit::static ->shouldReceive('getDateRange')->once()->andReturn([$start, $end]);//+//// // mock transaction journal+//// $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');+//// $tj->shouldReceive('getByDateRange')->with($start, $end)->andReturn([]);+////diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.phpindex 11d770ce15..c4a8bb2563 100644--- a/app/tests/controllers/HomeControllerTest.php+++ b/app/tests/controllers/HomeControllerTest.php@@ -13,12 +13,25 @@ class HomeControllerTest extends TestCaseView::shouldReceive('share');View::shouldReceive('make')->with('index')->once()->andReturn(\Mockery::self())->shouldReceive('with')->once() // Pass a 'with' parameter- ->with('count', 0);+ ->with('count', 0)->andReturn(\Mockery::self())+ ->shouldReceive('with')->once() // Pass a 'with' parameter+ ->with('transactions', [])->andReturn(\Mockery::self());++ // pass anotherAuth::shouldReceive('check')->andReturn(true);+// mock account repository$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');$accounts->shouldReceive('count')->andReturn(0);+ $accounts->shouldReceive('getActiveDefault')->andReturn([]);++ // mock preferences & pref:+ $pref = $this->mock('Preference');+ $pref->shouldReceive('getAttribute', 'data')->andReturn([]);++ $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');+ $preferences->shouldReceive('get')->with('frontpageAccounts', [])->once()->andReturn($pref);// call$this->call('GET', '/');