Skip to content

Firefly III: a personal finances manager

After quite some fumbling, fixed both the development import and some tests.

Sander Dorigobd315fb7cece
diff --git a/app/config/dev.php b/app/config/dev.php
new file mode 100644
index 0000000000..dc80c7748f
--- /dev/null
+++ b/app/config/dev.php
@@ -0,0 +1,4 @@
+<?php
+return [
+ 'import' => ''
+];
\ No newline at end of file
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index a5e90ae26e..bf87c445c9 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -20,6 +20,8 @@ class AccountController extends \BaseController
public function index()
{
$all = $this->accounts->get();
+
+
$list = [
'personal' => [],
'beneficiaries' => [],
diff --git a/app/controllers/MigrationController.php b/app/controllers/MigrationController.php
index 802856f6c0..1d0f8a293b 100644
--- a/app/controllers/MigrationController.php
+++ b/app/controllers/MigrationController.php
@@ -13,6 +13,20 @@ class MigrationController extends BaseController
}
+ public function dev() {
+ $file = Config::get('dev.import');
+ if(file_exists($file)) {
+ $user = User::find(1);
+ Auth::login($user);
+ /** @var Firefly\Helper\Migration\MigrationHelperInterface $migration */
+ $migration = App::make('Firefly\Helper\Migration\MigrationHelperInterface');
+ $migration->loadFile($file);
+ if ($migration->validFile()) {
+ $migration->migrate();
+ }
+ }
+ }
+
public function index()
{
return View::make('migrate.index');
diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php
index 96067d82dd..7c8e9d468c 100644
--- a/app/controllers/UserController.php
+++ b/app/controllers/UserController.php
@@ -26,15 +26,7 @@ class UserController extends BaseController
*/
public function login()
{
-// $user = User::find(1);
-// Auth::login($user);
-// /** @var Firefly\Helper\Migration\MigrationHelperInterface $migration */
-// $migration = App::make('Firefly\Helper\Migration\MigrationHelperInterface');
-// $file = '/Library/WebServer/Documents/projects/firefly-iii/app/storage/firefly-export-2014-07-06.json';
-// $migration->loadFile($file);
-// if($migration->validFile()) {
-// $migration->migrate();
-// }
+
return View::make('user.login');
diff --git a/app/routes.php b/app/routes.php
index 2fdbab8556..0e369b101f 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -23,6 +23,10 @@ Route::group(['before' => 'auth'], function () {
Route::get('/accounts/create', ['uses' => 'AccountController@create', 'as' => 'accounts.create']);
Route::get('/accounts/{account}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']);
+ // transaction controller:
+ Route::get('/transactions/add/withdrawal', ['uses' => 'TransactionController@createWithdrawal', 'as' => 'transactions.withdrawal']);
+ Route::get('/transactions/add/deposit', ['uses' => 'TransactionController@createDeposit', 'as' => 'transactions.deposit']);
+ Route::get('/transactions/add/transfer', ['uses' => 'TransactionController@createTransfer', 'as' => 'transactions.transfer']);
// migration controller
Route::get('/migrate', ['uses' => 'MigrationController@index', 'as' => 'migrate']);
@@ -54,6 +58,9 @@ Route::group(['before' => 'guest'], function () {
Route::get('/verify/{verification}', ['uses' => 'UserController@verify', 'as' => 'verify']);
Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
Route::get('/remindme', ['uses' => 'UserController@remindme', 'as' => 'remindme']);
+
+ // dev import route:
+ Route::get('/dev',['uses' => 'MigrationController@dev']);
}
);
diff --git a/app/tests/controllers/AccountControllerTest.php b/app/tests/controllers/AccountControllerTest.php
index ff1114f222..d45fe58ca9 100644
--- a/app/tests/controllers/AccountControllerTest.php
+++ b/app/tests/controllers/AccountControllerTest.php
@@ -1,32 +1,69 @@
<?php
+use Mockery as m;
+
class AccountControllerTest extends TestCase
{
public function setUp()
{
parent::setUp();
+ Artisan::call('migrate');
+ Artisan::call('db:seed');
}
public function testIndex()
{
+ // mock account type(s):
+ $personal = $this->mock('AccountType');
+ $personal->shouldReceive('getAttribute','description')->andReturn('Default account');
+
+ $bene = $this->mock('AccountType');
+ $bene->shouldReceive('getAttribute','description')->andReturn('Beneficiary account');
+
+ $initial = $this->mock('AccountType');
+ $initial->shouldReceive('getAttribute','description')->andReturn('Initial balance account');
+
+ $cash = $this->mock('AccountType');
+ $cash->shouldReceive('getAttribute','description')->andReturn('Cash account');
+
+
+
+ // mock account(s)
+ $one = $this->mock('Account');
+ $one->shouldReceive('getAttribute')->andReturn($personal);
+
+ $two = $this->mock('Account');
+ $two->shouldReceive('getAttribute')->andReturn($bene);
+
+ $three = $this->mock('Account');
+ $three->shouldReceive('getAttribute')->andReturn($initial);
+
+ $four = $this->mock('Account');
+ $four->shouldReceive('getAttribute')->andReturn($cash);
+ $c = new \Illuminate\Database\Eloquent\Collection([$one,$two,$three,$four]);
+
+ // mock account repository:
+ $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
+ $accounts->shouldReceive('get')->andReturn($c);
+
+
+
+
$list = [
- 'personal' => [],
- 'beneficiaries' => [],
- 'initial' => [],
- 'cash' => []
+ 'personal' => [$one],
+ 'beneficiaries' => [$two],
+ 'initial' => [$three],
+ 'cash' => [$four]
];
-
// mock:
View::shouldReceive('share');
View::shouldReceive('make')->with('accounts.index')->once()->andReturn(\Mockery::self())
- ->shouldReceive('with')->once()->with('accounts', $list)->andReturn(\Mockery::self())
- ->shouldReceive('with')->once()->with('total', 0)->andReturn(\Mockery::self());
+ ->shouldReceive('with')->once()->with('accounts',$list)->andReturn(\Mockery::self())
+ ->shouldReceive('with')->once()->with('total', 4)->andReturn(\Mockery::self());
+
- // mock account repository:
- $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
- $accounts->shouldReceive('get')->andReturn([]);
// call
$this->call('GET', '/accounts');
diff --git a/app/tests/models/TransactionJournalTest.php b/app/tests/models/TransactionJournalTest.php
index 06b9118300..540dfe2bd9 100644
--- a/app/tests/models/TransactionJournalTest.php
+++ b/app/tests/models/TransactionJournalTest.php
@@ -17,7 +17,7 @@ class TransactionJournalTest extends TestCase
*/
private function prepareForTests()
{
- Artisan::call('migrate');
+ Artisan::call('migrate');
}
/**
diff --git a/app/views/partials/menu/shared.blade.php b/app/views/partials/menu/shared.blade.php
index 89668f87ee..47771ffa2b 100644
--- a/app/views/partials/menu/shared.blade.php
+++ b/app/views/partials/menu/shared.blade.php
@@ -1,5 +1,19 @@
+<ul class="nav navbar-nav">
+
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Add... <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">
+
+ <li><a href="{{route('transactions.withdrawal')}}" title="For when you spend money"><span class="glyphicon glyphicon-arrow-left"></span> Withdrawal</a></li>
+ <li><a href="{{route('transactions.deposit')}}" title="For when you earn money"><span class="glyphicon glyphicon-arrow-right"></span> Deposit</a></li>
+ <li><a href="{{route('transactions.transfer')}}" title="For when you move money around"><span class="glyphicon glyphicon-resize-full"></span> Transfer</a></li>
+ </ul>
+ </li>
+</ul>
+
+
<ul class="nav navbar-nav navbar-right">
- <li @if($r=='settings')class="active"@endif><a href="{{route('preferences')}}"><span class="glyphicon glyphicon-cog"></span> Preferences</a></li>
+ <li @if($r=='preferences')class="active"@endif><a href="{{route('preferences')}}"><span class="glyphicon glyphicon-cog"></span> Preferences</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{{Auth::user()->email}}} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">