Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Updated some tests, fixed some bugs.
James Cole7af55b7268c3
diff --git a/.gitignore b/.gitignoreindex 7a425f757c..a76c7d4966 100644--- a/.gitignore+++ b/.gitignore@@ -18,3 +18,4 @@ tests/_output/*testing.sqlitec3.php_ide_helper_models.php+clean.sqlitediff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.phpindex 0eb2b58396..29b6dd02cb 100644--- a/app/controllers/GoogleChartController.php+++ b/app/controllers/GoogleChartController.php@@ -1,5 +1,6 @@<?phpuse Carbon\Carbon;+use Grumpydictator\Gchart\GChart as GChart;/*** Class GoogleChartController@@ -7,6 +8,18 @@ use Carbon\Carbon;class GoogleChartController extends BaseController{+ /** @var GChart */+ protected $_chart;++ /**+ * @param GChart $chart+ */+ public function __construct(GChart $chart)+ {+ $this->_chart = $chart;++ }+/*** @param Account $account* @param string $view@@ -15,55 +28,35 @@ class GoogleChartController extends BaseController*/public function accountBalanceChart(Account $account, $view = 'session'){- /** @var \Grumpydictator\Gchart\GChart $chart */- $chart = App::make('gchart');-- $chart->addColumn('Day of month', 'date');- $chart->addColumn('Balance for ' . $account->name, 'number');-- /*- * Loop the date, then loop the accounts, then add balance.- */- switch ($view) {- default:- case 'session':- $start = Session::get('start');- $end = Session::get('end');- break;- case 'all':- $first = $account->transactionjournals()->orderBy('date', 'DESC')->first();- $last = $account->transactionjournals()->orderBy('date', 'ASC')->first();- if (is_null($first)) {- $start = Session::get('start');- } else {- $start = clone $first->date;- }- if (is_null($last)) {- $end = Session::get('end');- } else {- $end = clone $last->date;- }- break;+ $this->_chart->addColumn('Day of month', 'date');+ $this->_chart->addColumn('Balance for ' . $account->name, 'number');++ $start = Session::get('start');+ $end = Session::get('end');+ $count = $account->transactions()->count();++ if ($view == 'all' && $count > 0) {+ $first = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(+ 'date', 'ASC'+ )->first(['transaction_journals.date']);+ $last = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy(+ 'date', 'DESC'+ )->first(['transaction_journals.date']);+ $start = new Carbon($first->date);+ $end = new Carbon($last->date);}$current = clone $start;while ($end >= $current) {- $row = [clone $current];- if ($current > Carbon::now()) {- $row[] = null;- } else {- $row[] = Steam::balance($account, $current);- }-- $chart->addRowArray($row);+ $this->_chart->addRow(clone $current, $current > Carbon::now() ? null : Steam::balance($account, $current));$current->addDay();}- $chart->generate();+ $this->_chart->generate();- return Response::json($chart->getData());+ return Response::json($this->_chart->getData());}/**diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.phpindex 202b8ebd11..dfaf035df3 100644--- a/app/database/seeds/TestContentSeeder.php+++ b/app/database/seeds/TestContentSeeder.php@@ -2,6 +2,9 @@use Carbon\Carbon;+/**+ * Class TestContentSeeder+ */class TestContentSeeder extends Seeder{@@ -27,6 +30,7 @@ class TestContentSeeder extends Seeder// create two asset accounts.$checking = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Checking account', 'active' => 1]);$savings = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Savings account', 'active' => 1]);+ $deleteMe = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1]);// create two budgets:$groceriesBudget = Budget::create(['user_id' => $user->id, 'name' => 'Groceries']);diff --git a/app/views/accounts/delete.blade.php b/app/views/accounts/delete.blade.phpindex 5140108559..0f60d5298d 100644--- a/app/views/accounts/delete.blade.php+++ b/app/views/accounts/delete.blade.php@@ -1,7 +1,7 @@@extends('layouts.default')@section('content'){{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) }}-{{Form::open(['class' => 'form-horizontal','url' => route('accounts.destroy',$account->id)])}}+{{Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('accounts.destroy',$account->id)])}}<div class="row"><div class="col-lg-6 col-md-12 col-sm-12"><div class="panel panel-red">@@ -29,16 +29,5 @@</div></div>-<div class="row">- <div class="col-lg-6">- <div class="form-group">- <div class="col-sm-8">-- </div>- </div>- </div>-</div>--{{Form::close()}}@stop\ No newline at end of filediff --git a/composer.json b/composer.jsonindex acd8fe328a..7b3fad61ff 100644--- a/composer.json+++ b/composer.json@@ -23,7 +23,7 @@"require": {"laravel/framework": "4.2.*","davejamesmiller/laravel-breadcrumbs": "2.*",- "grumpydictator/gchart": "dev-master",+ "grumpydictator/gchart": "1.*","michelf/php-markdown": "1.*","watson/validating": "0.10.*"},diff --git a/composer.lock b/composer.lockindex b05ef34b6b..0b40a3d726 100644--- a/composer.lock+++ b/composer.lock@@ -4,7 +4,7 @@"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file","This file is @generated automatically"],- "hash": "248937553255d85014e6ec3b32115848",+ "hash": "4149e5d1a8b58787b3e9f68fc8cf40b9","packages": [{"name": "classpreloader/classpreloader",@@ -195,7 +195,7 @@},{"name": "grumpydictator/gchart",- "version": "dev-master",+ "version": "1.0.0","source": {"type": "git","url": "https://github.com/JC5/gchart.git",@@ -324,16 +324,16 @@},{"name": "laravel/framework",- "version": "v4.2.11",+ "version": "v4.2.12","source": {"type": "git","url": "https://github.com/laravel/framework.git",- "reference": "e29253c7f29e3b1ca716de7fe309b272e3ddf47d"+ "reference": "70a60f2ff9b96b3fcd88a68ef5382557733fe671"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/laravel/framework/zipball/e29253c7f29e3b1ca716de7fe309b272e3ddf47d",- "reference": "e29253c7f29e3b1ca716de7fe309b272e3ddf47d",+ "url": "https://api.github.com/repos/laravel/framework/zipball/70a60f2ff9b96b3fcd88a68ef5382557733fe671",+ "reference": "70a60f2ff9b96b3fcd88a68ef5382557733fe671","shasum": ""},"require": {@@ -435,7 +435,7 @@"framework","laravel"],- "time": "2014-10-04 18:48:27"+ "time": "2014-12-11 17:14:36"},{"name": "michelf/php-markdown",@@ -2828,16 +2828,16 @@},{"name": "guzzlehttp/ringphp",- "version": "1.0.4",+ "version": "1.0.5","source": {"type": "git","url": "https://github.com/guzzle/RingPHP.git",- "reference": "9187999f80720b9494692d2167d75144acb2ad05"+ "reference": "a903f51b692427318bc813217c0e6505287e79a4"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/9187999f80720b9494692d2167d75144acb2ad05",- "reference": "9187999f80720b9494692d2167d75144acb2ad05",+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a903f51b692427318bc813217c0e6505287e79a4",+ "reference": "a903f51b692427318bc813217c0e6505287e79a4","shasum": ""},"require": {@@ -2874,7 +2874,7 @@"homepage": "https://github.com/mtdowling"}],- "time": "2014-12-02 05:01:22"+ "time": "2014-12-11 05:50:32"},{"name": "guzzlehttp/streams",@@ -4162,7 +4162,6 @@"aliases": [],"minimum-stability": "stable","stability-flags": {- "grumpydictator/gchart": 20,"barryvdh/laravel-debugbar": 0,"barryvdh/laravel-ide-helper": 0,"satooshi/php-coveralls": 20,diff --git a/tests/_bootstrap.php b/tests/_bootstrap.phpindex 14f1eda6e0..114e9e4b81 100644--- a/tests/_bootstrap.php+++ b/tests/_bootstrap.php@@ -1,8 +1,24 @@<?php// This is global bootstrap for autoloading-$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';+$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';if (!file_exists($db)) {exec('touch ' . $db);exec('php artisan migrate --seed --env=testing');}+exec('cp ' . $db . ' ' . realpath(__DIR__ . '/_data') . '/clean.sqlite');++/**+ * Class resetToClean+ * @SuppressWarnings("CamelCase")+ */+class resetToClean+{+ /**+ *+ */+ static public function clean()+ {+ exec('cp ' . realpath(__DIR__ . '/_data') . '/clean.sqlite ' . realpath(__DIR__ . '/_data') . '/testing.sqlite');+ }+}\ No newline at end of filediff --git a/tests/functional/AccountControllerCest.php b/tests/functional/AccountControllerCest.phpnew file mode 100644index 0000000000..704bcf51fb--- /dev/null+++ b/tests/functional/AccountControllerCest.php@@ -0,0 +1,106 @@+<?php+use Carbon\Carbon;++/**+ * Class AccountControllerCest+ */+class AccountControllerCest+{+ /**+ * @param FunctionalTester $I+ */+ public function _after(FunctionalTester $I)+ {+ }++ /**+ * @param FunctionalTester $I+ */+ public function _before(FunctionalTester $I)+ {+ $I->amLoggedAs(['email' => '[email protected]', 'password' => 'james']);++ Session::put('start', new Carbon);+ Session::put('end', new Carbon);+++ }++ /**+ * @param FunctionalTester $I+ */+ public function create(FunctionalTester $I)+ {+ // @codingStandardsIgnoreStart+ $I->wantTo('create a new asset account');+ $I->amOnPage('/accounts/create/asset');+ $I->see('Create a new asset account');+ }++ /**+ * @param FunctionalTester $I+ */+ public function delete(FunctionalTester $I)+ {+ $I->wantTo('delete an asset account');+ $I->amOnPage('/accounts/delete/3');+ $I->see('Delete account "Delete me"');+ }++ /**+ * @param FunctionalTester $I+ */+ public function destroy(FunctionalTester $I)+ {+ $I->wantTo('destroy an asset account');+ }++ /**+ * @param FunctionalTester $I+ */+ public function edit(FunctionalTester $I)+ {+ $I->wantTo('delete an asset account');+ $I->amOnPage('/accounts/edit/3');+ $I->see('Edit asset account "Delete me"');+ }++ /**+ * @param FunctionalTester $I+ */+ public function index(FunctionalTester $I)+ {+ $I->wantTo('see a list of accounts');+ $I->amOnPage('/accounts/asset');+ $I->see('Checking account');+ $I->see('Delete me');+ }++ /**+ * @param FunctionalTester $I+ */+ public function show(FunctionalTester $I)+ {+ $I->wantTo('see one account');+ #$I->amOnPage('/accounts/show/3');+ #$I->see('Details for');+ #$I->see('Delete me');+ }++ /**+ * @param FunctionalTester $I+ */+ public function store(FunctionalTester $I)+ {+ $I->wantTo('store a new asset account');+ }++ /**+ * @param FunctionalTester $I+ */+ public function update(FunctionalTester $I)+ {+ $I->wantTo('update an asset account');+ }++}\ No newline at end of filediff --git a/tests/functional/UserControllerCest.php b/tests/functional/UserControllerCest.phpindex ce7340c404..06050c1bb6 100644--- a/tests/functional/UserControllerCest.php+++ b/tests/functional/UserControllerCest.php@@ -1,5 +1,11 @@<?php+/**+ * Class UserControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")+ */class UserControllerCest{/**@@ -24,11 +30,24 @@ class UserControllerCest$I->wantTo('login');$I->amOnPage('/login');$I->see('Sign In');- $I->submitForm('#login', ['email' => '[email protected]','password' => 'functional']);+ $I->submitForm('#login', ['email' => '[email protected]', 'password' => 'functional']);$I->see('[email protected]');}+ /**+ * @param FunctionalTester $I+ */+ public function loginFails(FunctionalTester $I)+ {+ $I->wantTo('fail the login');+ $I->amOnPage('/login');+ $I->see('Sign In');+ $I->submitForm('#login', ['email' => '[email protected]', 'password' => 'wrong']);+ $I->see('No good');++ }+/*** @param FunctionalTester $I*/@@ -57,7 +76,7 @@ class UserControllerCest$I->wantTo('post-register a new account');$I->amOnPage('/register');$token = $I->grabValueFrom('input[name=_token]');- $I->submitForm('#register', ['email' => '[email protected]','_token' => $token]);+ $I->submitForm('#register', ['email' => '[email protected]', '_token' => $token]);$I->see('Password sent!');$I->seeRecord('users', ['email' => '[email protected]']);// @codingStandardsIgnoreEnd