mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
After quite some fumbling, fixed both the development import and some tests.
This commit is contained in:
4
app/config/dev.php
Normal file
4
app/config/dev.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'import' => ''
|
||||
];
|
@@ -20,6 +20,8 @@ class AccountController extends \BaseController
|
||||
public function index()
|
||||
{
|
||||
$all = $this->accounts->get();
|
||||
|
||||
|
||||
$list = [
|
||||
'personal' => [],
|
||||
'beneficiaries' => [],
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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']);
|
||||
}
|
||||
);
|
||||
|
||||
|
@@ -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');
|
||||
|
@@ -17,7 +17,7 @@ class TransactionJournalTest extends TestCase
|
||||
*/
|
||||
private function prepareForTests()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user