From cc71a1116a4c115329adee9f9b41894b3dc2cea1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 23 Jul 2014 06:57:51 +0200 Subject: [PATCH] Some new tests and fixes. [skip ci] --- app/controllers/BudgetController.php | 18 +-- app/controllers/ChartController.php | 8 +- app/filters.php | 2 +- .../Firefly/Helper/HelperServiceProvider.php | 5 + app/lib/Firefly/Helper/Toolkit/Toolkit.php | 7 +- .../Budget/BudgetRepositoryInterface.php | 2 +- .../Budget/EloquentBudgetRepository.php | 2 +- app/models/Limit.php | 57 ++++--- app/models/LimitRepetition.php | 16 +- app/models/TransactionJournal.php | 15 +- app/routes.php | 2 +- .../controllers/BudgetControllerTest.php | 121 ++++++++++++++ app/tests/controllers/ChartControllerTest.php | 153 ++++++++++++++---- app/tests/controllers/HomeControllerTest.php | 53 +++++- app/views/transactions/create.blade.php | 33 ++-- 15 files changed, 397 insertions(+), 97 deletions(-) create mode 100644 app/tests/controllers/BudgetControllerTest.php diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php index 8dedc33674..f3453657ed 100644 --- a/app/controllers/BudgetController.php +++ b/app/controllers/BudgetController.php @@ -87,7 +87,7 @@ class BudgetController extends BaseController 'repeats' => intval(Input::get('repeats')) ]; - $budget = $this->_budgets->create($data); + $this->_budgets->store($data); Session::flash('success', 'Budget created!'); return Redirect::route('budgets.index'); } @@ -106,31 +106,29 @@ class BudgetController extends BaseController $return[$month][] = $entry; } + $str = ''; foreach ($return as $month => $set) { - echo '

' . $month . '

'; + $str .= '

' . $month . '

'; /** @var \TransactionJournal $tj */ $sum = 0; foreach ($set as $tj) { - echo '#' . $tj->id . ' ' . $tj->description . ': '; + $str .= '#' . $tj->id . ' ' . $tj->description . ': '; foreach ($tj->transactions as $index => $t) { - echo $t->amount . ', '; + $str .= $t->amount . ', '; if ($index == 0) { $sum += $t->amount; } } - echo '
'; + $str .= '
'; } - echo 'sum: ' . $sum . '

'; + $str .= 'sum: ' . $sum . '

'; } - - exit; - - return View::make('budgets.show'); + return $str; } diff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.php index d596d06367..fcbe9f5f2e 100644 --- a/app/controllers/ChartController.php +++ b/app/controllers/ChartController.php @@ -1,7 +1,8 @@ _tk->getDateRange(); + \Log::debug('Start is (cannot clone?): ' . $start); $current = clone $start; $return = []; $account = null; @@ -73,8 +75,10 @@ class ChartController extends BaseController } } else { $return[0] = ['name' => $account->name, 'id' => $account->id, 'data' => []]; - + \Log::debug('Start is: '.$start); + \Log::debug('End is: '.$end); while ($current <= $end) { + \Log::debug('Current: ' . $current.' is smaller or equal to ' . $end); if ($current > $today) { $return[0]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)]; } else { diff --git a/app/filters.php b/app/filters.php index 27afed181e..dd76464e1d 100644 --- a/app/filters.php +++ b/app/filters.php @@ -5,7 +5,7 @@ App::before( function ($request) { if (Auth::check()) { - $toolkit = App::make('\Firefly\Helper\Toolkit\ToolkitInterface'); + $toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface'); $toolkit->getDateRange(); } Event::fire('app.before'); diff --git a/app/lib/Firefly/Helper/HelperServiceProvider.php b/app/lib/Firefly/Helper/HelperServiceProvider.php index a3d685febf..06431f8d3f 100644 --- a/app/lib/Firefly/Helper/HelperServiceProvider.php +++ b/app/lib/Firefly/Helper/HelperServiceProvider.php @@ -27,6 +27,11 @@ class HelperServiceProvider extends ServiceProvider 'Firefly\Helper\Preferences\PreferencesHelperInterface', 'Firefly\Helper\Preferences\PreferencesHelper' ); + // settings: + $this->app->bind( + 'Firefly\Helper\Toolkit\ToolkitInterface', + 'Firefly\Helper\Toolkit\Toolkit' + ); } } \ No newline at end of file diff --git a/app/lib/Firefly/Helper/Toolkit/Toolkit.php b/app/lib/Firefly/Helper/Toolkit/Toolkit.php index 088fb7a6bc..1fea808409 100644 --- a/app/lib/Firefly/Helper/Toolkit/Toolkit.php +++ b/app/lib/Firefly/Helper/Toolkit/Toolkit.php @@ -2,7 +2,11 @@ namespace Firefly\Helper\Toolkit; - +/** + * Class Toolkit + * + * @package Firefly\Helper\Toolkit + */ class Toolkit implements ToolkitInterface { @@ -16,6 +20,7 @@ class Toolkit implements ToolkitInterface */ public function getDateRange() { + \Log::debug('Should be mocked!'); $preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface'); $viewRange = $preferences->get('viewRange', '1M'); diff --git a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php index f15e406e74..1271ee6103 100644 --- a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php @@ -8,7 +8,7 @@ interface BudgetRepositoryInterface public function getAsSelectList(); public function get(); - public function create($data); + public function store($data); public function find($id); diff --git a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php index b5b241253d..d43118b8f6 100644 --- a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php +++ b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php @@ -18,7 +18,7 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface return $return; } - public function create($data) + public function store($data) { $budget = new \Budget; $budget->name = $data['name']; diff --git a/app/models/Limit.php b/app/models/Limit.php index ac0444131b..a83594d5eb 100644 --- a/app/models/Limit.php +++ b/app/models/Limit.php @@ -5,25 +5,25 @@ use LaravelBook\Ardent\Ardent as Ardent; /** * Limit * - * @property integer $id - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * @property integer $component_id - * @property \Carbon\Carbon $startdate - * @property float $amount - * @property boolean $repeats - * @property string $repeat_freq - * @property-read \Component $component - * @property-read \Budget $budget + * @property integer $id + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property integer $component_id + * @property \Carbon\Carbon $startdate + * @property float $amount + * @property boolean $repeats + * @property string $repeat_freq + * @property-read \Component $component + * @property-read \Budget $budget * @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions - * @method static \Illuminate\Database\Query\Builder|\Limit whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value) */ class Limit extends Ardent { @@ -38,17 +38,23 @@ class Limit extends Ardent ]; - public static $factory - = [ + public static function factory() + { + $start = new Carbon\Carbon; + $start->startOfMonth(); + + return [ 'component_id' => 'factory|Budget', - 'startdate' => 'date', - 'enddate' => 'date', - 'amount' => '100' + 'startdate' => $start, + 'amount' => '100', + 'repeats' => 0, + 'repeat_freq' => 'monthly' ]; + } public function component() { - return $this->belongsTo('Component','component_id'); + return $this->belongsTo('Component', 'component_id'); } public function budget() @@ -56,7 +62,8 @@ class Limit extends Ardent return $this->belongsTo('Budget', 'component_id'); } - public function limitrepetitions() { + public function limitrepetitions() + { return $this->hasMany('LimitRepetition'); } diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php index 5dfbd1c2ba..df8c26e6f5 100644 --- a/app/models/LimitRepetition.php +++ b/app/models/LimitRepetition.php @@ -31,13 +31,19 @@ class LimitRepetition extends Ardent 'amount' => 'numeric|required|min:0.01', ]; - public static $factory - = [ + public static function factory() + { + $start = new \Carbon\Carbon; + $start->startOfMonth(); + $end = clone $start; + $end->endOfMonth(); + return [ 'limit_id' => 'factory|Limit', - 'startdate' => 'date', - 'enddate' => 'date', - 'amount' => 'integer' + 'startdate' => $start, + 'enddate' => $end, + 'amount' => 100 ]; + } public function limit() { diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index 3d28bb0398..676303a5fc 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -32,13 +32,13 @@ use LaravelBook\Ardent\Ardent; * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value) * @method static \TransactionJournal after($date) * @method static \TransactionJournal before($date) - * @property integer $user_id - * @property-read \User $user + * @property integer $user_id + * @property-read \User $user * @property-read \Illuminate\Database\Eloquent\Collection|\ * 'Budget[] $budgets * @property-read \Illuminate\Database\Eloquent\Collection|\ * 'Category[] $categories - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value) */ class TransactionJournal extends Ardent { @@ -52,15 +52,18 @@ class TransactionJournal extends Ardent 'completed' => 'required|between:0,1' ]; - public static $factory - = [ + public static function factory() + { + $date = new \Carbon\Carbon; + return [ 'transaction_type_id' => 'factory|TransactionType', 'transaction_currency_id' => 'factory|TransactionCurrency', 'description' => 'string', 'completed' => '1', 'user_id' => 'factory|User', - 'date' => 'date|Y-m-d' + 'date' => $date ]; + } public function transactionType() { diff --git a/app/routes.php b/app/routes.php index 45e888e7e1..827c4827bb 100644 --- a/app/routes.php +++ b/app/routes.php @@ -27,8 +27,8 @@ Route::group(['before' => 'auth'], function () { Route::get('/accounts/{account}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']); // budget controller: - Route::get('/budgets/{group?}',['uses' => 'BudgetController@index','as' => 'budgets.index']); Route::get('/budget/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']); + Route::get('/budgets/{group?}',['uses' => 'BudgetController@index','as' => 'budgets.index']); Route::get('/budget/show/{id}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']); // limit controller: diff --git a/app/tests/controllers/BudgetControllerTest.php b/app/tests/controllers/BudgetControllerTest.php new file mode 100644 index 0000000000..b48e620f1c --- /dev/null +++ b/app/tests/controllers/BudgetControllerTest.php @@ -0,0 +1,121 @@ +limitrepetitions()->save($rep); + $budget->limits()->save($limit); + + + + // mock budget repository: + $budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface'); + $budgets->shouldReceive('get')->once()->andReturn([$budget]); + + // call + $this->call('GET', '/budgets/date'); + + // test + $this->assertResponseOk(); + } + + public function testIndexBudget() + { + // create some objects: + $budget = FactoryMuffin::create('Budget'); + $limit = FactoryMuffin::create('Limit'); + $rep = FactoryMuffin::create('LimitRepetition'); + $limit->limitrepetitions()->save($rep); + $budget->limits()->save($limit); + + + + // mock budget repository: + $budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface'); + $budgets->shouldReceive('get')->once()->andReturn([$budget]); + + // call + $this->call('GET', '/budgets/budget'); + + // test + $this->assertResponseOk(); + } + + public function testCreate() + { + // call + $this->call('GET', '/budget/create'); + + // test + $this->assertResponseOk(); + } + + public function testStore() + { + $data = [ + 'name' => 'X', + 'amount' => 100, + 'period' => 'monthly', + 'repeats' => 0 + ]; + $return = $data; + $return['repeat_freq'] = 'monthly'; + unset($return['period']); + + // mock budget repository: + $budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface'); + $budgets->shouldReceive('store')->with($return)->once()->andReturn(true); + + // call + $this->call('POST', '/budget/store',$data); + + // test + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); + } + + public function testShow() + { + $budget = FactoryMuffin::create('Budget'); + $journal = FactoryMuffin::create('TransactionJournal'); + $transaction = FactoryMuffin::create('Transaction'); + $journal->transactions()->save($transaction); + $budget->transactionjournals()->save($journal); + + + // mock budget repository: + $budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface'); + $budgets->shouldReceive('find')->with($budget->id)->once()->andReturn($budget); + + + // call + $this->call('GET', '/budget/show/'.$budget->id); + + // test + $this->assertResponseOk(); + } + + public function tearDown() + { + Mockery::close(); + } + + +} \ No newline at end of file diff --git a/app/tests/controllers/ChartControllerTest.php b/app/tests/controllers/ChartControllerTest.php index 186d298dda..ad67fa479c 100644 --- a/app/tests/controllers/ChartControllerTest.php +++ b/app/tests/controllers/ChartControllerTest.php @@ -14,20 +14,21 @@ class ChartControllerTest extends TestCase public function testHomeAccount() { // mock preference: - $pref = $this->mock('Preference'); - $pref->shouldReceive('getAttribute', 'data')->andReturn('1M'); $pref2 = $this->mock('Preference'); $pref2->shouldReceive('getAttribute', 'data')->andReturn([]); // mock preferences helper: $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); - $preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref); $preferences->shouldReceive('get')->with('frontpageAccounts', [])->once()->andReturn($pref2); // mock toolkit: + $start = new Carbon\Carbon; + $start->startOfMonth(); + $end = new \Carbon\Carbon; + $end->endOfMonth(); $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface'); - $toolkit->shouldReceive('getDateRange')->andReturn(null); + $toolkit->shouldReceive('getDateRange')->with()->once()->andReturn([$start, $end]); // create a semi-mocked collection of accounts: @@ -55,22 +56,65 @@ class ChartControllerTest extends TestCase $this->assertResponseOk(); } + public function testHomeAccountWithPref() + { + + // mock toolkit: + $start = new Carbon\Carbon; + $start->startOfMonth(); + $end = new \Carbon\Carbon; + $end->endOfMonth(); + $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface'); + $toolkit->shouldReceive('getDateRange')->with()->once()->andReturn([$start, $end]); + + // mock account(s) + $personal = $this->mock('AccountType'); + $personal->shouldReceive('jsonSerialize')->andReturn(''); + + $one = $this->mock('Account'); + $one->shouldReceive('getAttribute')->andReturn($personal); + $one->shouldReceive('balance')->andReturn(0); + $one->shouldReceive('predict')->andReturn(null); + + // collection: + $c = new \Illuminate\Database\Eloquent\Collection([$one]); + + // mock preference: + $pref2 = $this->mock('Preference'); + $pref2->shouldReceive('getAttribute', 'data')->andReturn([$one->id]); + + // mock preferences helper: + $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); + $preferences->shouldReceive('get')->with('frontpageAccounts', [])->once()->andReturn($pref2); + + + // create a semi-mocked collection of accounts: + + + // mock account repository: + $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); + $accounts->shouldReceive('getByIds')->andReturn($c); + + + // call + $this->call('GET', '/chart/home/account'); + + // test + $this->assertResponseOk(); + } + public function testHomeAccountWithInput() { // save actual account: $account = FactoryMuffin::create('Account'); - // mock preference: - $pref = $this->mock('Preference'); - $pref->shouldReceive('getAttribute', 'data')->andReturn('week'); - - // mock preferences helper: - $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); - $preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref); - // mock toolkit: + $start = new Carbon\Carbon; + $start->startOfMonth(); + $end = new \Carbon\Carbon; + $end->endOfMonth(); $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface'); - $toolkit->shouldReceive('getDateRange')->andReturn(null); + $toolkit->shouldReceive('getDateRange')->with()->once()->andReturn([$start, $end]); // mock account repository: $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); @@ -89,30 +133,17 @@ class ChartControllerTest extends TestCase $start = new \Carbon\Carbon; $end = new \Carbon\Carbon; - // mock preferences & pref: - $pref = $this->mock('Preference'); - $pref->shouldReceive('getAttribute', 'data')->andReturn([]); + // mock journals: + $transaction = FactoryMuffin::create('Transaction'); + $journal = FactoryMuffin::create('TransactionJournal'); + $journal->transactions()->save($transaction); + $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface'); + $tj->shouldReceive('getByDateRange')->once()->with($start, $end)->andReturn([$journal]); // 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([]); -//// - // call $this->call('GET', '/chart/home/categories'); @@ -121,6 +152,64 @@ class ChartControllerTest extends TestCase $this->assertResponseOk(); } + /** + * @expectedException \Firefly\Exception\FireflyException + */ + public function testhomeCategoriesException() + { + $start = new \Carbon\Carbon; + $end = new \Carbon\Carbon; + + // mock journals: + $journal = FactoryMuffin::create('TransactionJournal'); + $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface'); + $tj->shouldReceive('getByDateRange')->once()->with($start, $end)->andReturn([$journal]); + + + // mock toolkit + $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface'); + $toolkit->shouldReceive('getDateRange')->andReturn([$start, $end]); + + // call + $this->call('GET', '/chart/home/categories'); + + // test + $this->assertResponseOk(); + } + + public function testHomeAccountInfo() + { + $account = FactoryMuffin::create('Account'); + $second = FactoryMuffin::create('Account'); + $date = \Carbon\Carbon::createFromDate('2012','01','01'); + $transaction = FactoryMuffin::create('Transaction'); + $transaction->account()->associate($second); + $journal = FactoryMuffin::create('TransactionJournal'); + $journal->transactions()->save($transaction); + + // mock account repository: + $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); + $accounts->shouldReceive('findByName')->with($account->name)->andReturn($account); + + // mock journal: + $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface'); + $tj->shouldReceive('getByAccountAndDate')->once()->andReturn([$journal]); + + + + + + + + // call + $this->call('GET', '/chart/home/info/'.$account->name.'/'.$date->format('d/m/Y')); + + // test + $this->assertResponseOk(); + + + } //($name, $day, $month, $year) + public function tearDown() { Mockery::close(); diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.php index c4a8bb2563..b76498563c 100644 --- a/app/tests/controllers/HomeControllerTest.php +++ b/app/tests/controllers/HomeControllerTest.php @@ -1,10 +1,17 @@ with('index')->once()->andReturn(\Mockery::self()) - ->shouldReceive('with')->once() // Pass a 'with' parameter + ->shouldReceive('with')->once() // Pass a 'with' parameter ->with('count', 0)->andReturn(\Mockery::self()) - ->shouldReceive('with')->once() // Pass a 'with' parameter + ->shouldReceive('with')->once() // Pass a 'with' parameter ->with('transactions', [])->andReturn(\Mockery::self()); - // pass another + // pass another Auth::shouldReceive('check')->andReturn(true); @@ -40,6 +47,46 @@ class HomeControllerTest extends TestCase $this->assertResponseOk(); } + public function testIndexWithAccounts() + { + // mock: + View::shouldReceive('share'); + View::shouldReceive('make')->with('index')->once()->andReturn(\Mockery::self()) + ->shouldReceive('with')->once() // Pass a 'with' parameter + ->with('count', 1)->andReturn(\Mockery::self()) + ->shouldReceive('with')->once() // Pass a 'with' parameter + ->with('transactions', [])->andReturn(\Mockery::self()); + + // pass another + Auth::shouldReceive('check')->andReturn(true); + + // make account: + $account = FactoryMuffin::create('Account'); + + + // mock account repository + $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); + $accounts->shouldReceive('count')->andReturn(1); + $accounts->shouldReceive('getByIds')->with([$account->id])->andReturn([$account]); + + // mock transaction journal repository: + $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface'); + $tj->shouldReceive('getByAccount')->with($account,15)->andReturn([]); + + // mock preferences & pref: + $pref = $this->mock('Preference'); + $pref->shouldReceive('getAttribute', 'data')->andReturn([$account->id]); + + $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); + $preferences->shouldReceive('get')->with('frontpageAccounts', [])->once()->andReturn($pref); + + // call + $this->call('GET', '/'); + + // test + $this->assertResponseOk(); + } + public function tearDown() { Mockery::close(); diff --git a/app/views/transactions/create.blade.php b/app/views/transactions/create.blade.php index 8f5ade4321..c3f5c76928 100644 --- a/app/views/transactions/create.blade.php +++ b/app/views/transactions/create.blade.php @@ -119,14 +119,6 @@ - -
- -
- -
-
-

Optional fields

@@ -154,8 +146,31 @@
+ - +
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+ +
+
+
+
@stop @section('scripts')