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 @@ + '' +]; \ 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 @@ 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 @@ +
+ +