Compare commits

...

44 Commits

Author SHA1 Message Date
James Cole
3d9755ca8c Merge branch 'release/3.4.0.9' 2015-05-24 11:53:43 +02:00
James Cole
b5cf2d03e6 New version. 2015-05-24 11:53:34 +02:00
James Cole
e3b35b8f35 Add code climate file [skip ci] 2015-05-24 11:46:41 +02:00
James Cole
1c1fe672bd Some code cleanup [skip ci] 2015-05-24 11:41:52 +02:00
James Cole
6c71f68ed8 Should cover models. 2015-05-24 11:13:46 +02:00
James Cole
8f2f912cdf New (empty) tests for models. 2015-05-24 10:01:00 +02:00
James Cole
bf6ea16acb Fixed test. 2015-05-24 09:29:44 +02:00
James Cole
288546c2b9 Fixed some math. 2015-05-24 08:00:40 +02:00
James Cole
724db6c34c Built some new tests 2015-05-24 07:43:48 +02:00
James Cole
067c451c1d Fixed tests 2015-05-23 21:41:04 +02:00
James Cole
11e3696191 Cleanup tests. 2015-05-23 21:23:51 +02:00
James Cole
41e20664de Fixed coverage. 2015-05-23 21:18:20 +02:00
James Cole
d8de90d6f3 Ignore constructors. 2015-05-23 20:49:57 +02:00
James Cole
b01e8299d3 Fixed tests 2015-05-23 20:47:31 +02:00
James Cole
1ec11e3e2e Compartmentalised all tests. 2015-05-23 19:41:54 +02:00
James Cole
422f429725 Experimental count thing. 2015-05-23 17:38:16 +02:00
James Cole
5c55fa5fbb Remove encrypted amounts because it stinks. 2015-05-23 17:33:04 +02:00
James Cole
80d845fdf2 Save but don't use. 2015-05-23 17:18:23 +02:00
James Cole
601fe68346 Don't multiply transactions. 2015-05-23 17:14:36 +02:00
James Cole
9e050fb059 Updated some tests. 2015-05-23 17:11:16 +02:00
James Cole
99d4adf5e6 Translations [skip ci] 2015-05-23 15:57:38 +02:00
James Cole
85f8d1e8e9 Math is hard [skip ci] 2015-05-23 15:45:01 +02:00
James Cole
8334d3d99f Translation error [skip ci] 2015-05-23 15:43:48 +02:00
James Cole
cff08d19eb Slowly move away from using the raw 'transactions.amount' field. 2015-05-23 15:42:19 +02:00
James Cole
2d86390bc1 Experimental query.Code cleanup [skip ci] 2015-05-23 09:11:59 +02:00
James Cole
7a20835571 Code cleanup [skip ci] 2015-05-23 09:09:25 +02:00
James Cole
ff3c9676b5 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:05:08 +02:00
James Cole
055f97dab1 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:03:52 +02:00
James Cole
8a867e71a1 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:02:27 +02:00
James Cole
b8275b4734 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:01:38 +02:00
James Cole
36b951b146 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:01:07 +02:00
James Cole
c5a5f17643 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 09:00:11 +02:00
James Cole
16b909c4df Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 08:59:23 +02:00
James Cole
92b7648e03 Encrypt more stuff in the cleanup routine [skip ci] 2015-05-23 08:58:21 +02:00
James Cole
ca46ebe3b2 Encrypt bill amounts [skip ci] 2015-05-23 08:57:02 +02:00
James Cole
676e48254a Whoops [skip ci] 2015-05-23 08:55:16 +02:00
James Cole
b15b55227d Add another cleanup routine. [skip ci] 2015-05-23 08:54:25 +02:00
James Cole
3c3b723913 Some code cleanup [skip ci] 2015-05-23 08:51:24 +02:00
James Cole
f05002c729 Updated models for encryption. 2015-05-23 08:46:46 +02:00
James Cole
1c2cbd5b40 New stuff for encrypted amounts. 2015-05-23 07:47:36 +02:00
James Cole
54c6ca9f45 Expanded some tests. 2015-05-22 20:25:12 +02:00
James Cole
c10efbb170 Also encrypt meta data for reminders. 2015-05-22 19:19:18 +02:00
James Cole
a496ad5814 Simple routine to encrypt entries which were not encrypted yet. 2015-05-22 19:18:00 +02:00
James Cole
f946f10afd Merge branch 'release/3.4.0.8' into develop 2015-05-22 18:55:13 +02:00
98 changed files with 2664 additions and 446 deletions

23
.codeclimate.yml Normal file
View File

@@ -0,0 +1,23 @@
# Save as .codeclimate.yml (note leading .) in project root directory
languages:
JavaScript: true
PHP: true
exclude_paths:
- "public/packages/maximebf/php-debugbar/debugbar.js"
- "public/packages/maximebf/php-debugbar/widgets.js"
- "public/packages/maximebf/php-debugbar/openhandler.js"
- "public/packages/maximebf/php-debugbar/widgets/sqlqueries/widget.js"
- "public/js/bootstrap3-typeahead.min.js"
- "public/js/bootstrap-sortable.js"
- "public/js/bootstrap-tagsinput.min.js"
- "public/js/bootstrap-tagsinput.min.js.map"
- "public/js/daterangepicker.js"
- "public/js/jquery-2.1.3.min.js"
- "public/js/jquery-2.1.3.min.js.map"
- "public/js/jquery-ui.min.js"
- "public/js/metisMenu.js"
- "public/js/moment.min.js"
- "public/js/sb-admin-2.js"
- "tests/*"
- "database/*"
- "storage/*"

View File

@@ -17,3 +17,4 @@ EMAIL_USERNAME=
EMAIL_PASSWORD= EMAIL_PASSWORD=
ANALYTICS_ID= ANALYTICS_ID=
EMAIL_PRETEND=false EMAIL_PRETEND=false
RUNCLEANUP=true

View File

@@ -1,5 +1,5 @@
# Firefly III # Firefly III
#### v3.4.0.8 #### v3.4.0.9
[![Build Status](https://travis-ci.org/JC5/firefly-iii.svg?branch=develop)](https://travis-ci.org/JC5/firefly-iii) [![Build Status](https://travis-ci.org/JC5/firefly-iii.svg?branch=develop)](https://travis-ci.org/JC5/firefly-iii)
[![Project Status](http://stillmaintained.com/JC5/firefly-iii.png?a=b)](http://stillmaintained.com/JC5/firefly-iii) [![Project Status](http://stillmaintained.com/JC5/firefly-iii.png?a=b)](http://stillmaintained.com/JC5/firefly-iii)

View File

@@ -18,6 +18,8 @@ class ConnectJournalToPiggyBank
/** /**
* Create the event handler. * Create the event handler.
* *
* @codeCoverageIgnore
*
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -15,14 +15,14 @@ class Budget
{ {
/** @var Collection */ /** @var Collection */
protected $budgetLines; protected $budgetLines;
/** @var float */ /** @var string */
protected $budgeted = 0; protected $budgeted = '0';
/** @var float */ /** @var string */
protected $left = 0; protected $left = '0';
/** @var float */ /** @var string */
protected $overspent = 0; protected $overspent = '0';
/** @var float */ /** @var string */
protected $spent = 0; protected $spent = '0';
/** /**
* *
@@ -45,7 +45,9 @@ class Budget
*/ */
public function addBudgeted($add) public function addBudgeted($add)
{ {
$this->budgeted += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->budgeted = bcadd($this->budgeted, $add);
} }
/** /**
@@ -53,7 +55,9 @@ class Budget
*/ */
public function addLeft($add) public function addLeft($add)
{ {
$this->left += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->left = bcadd($this->left, $add);
} }
/** /**
@@ -61,7 +65,9 @@ class Budget
*/ */
public function addOverspent($add) public function addOverspent($add)
{ {
$this->overspent += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->overspent = bcadd($this->overspent, $add);
} }
/** /**
@@ -69,7 +75,9 @@ class Budget
*/ */
public function addSpent($add) public function addSpent($add)
{ {
$this->spent += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->spent = bcadd($this->spent, $add);
} }
/** /**
@@ -81,7 +89,7 @@ class Budget
} }
/** /**
* @return float * @return string
*/ */
public function getBudgeted() public function getBudgeted()
{ {
@@ -89,7 +97,7 @@ class Budget
} }
/** /**
* @param float $budgeted * @param string $budgeted
*/ */
public function setBudgeted($budgeted) public function setBudgeted($budgeted)
{ {
@@ -97,7 +105,7 @@ class Budget
} }
/** /**
* @return float * @return string
*/ */
public function getLeft() public function getLeft()
{ {
@@ -105,7 +113,7 @@ class Budget
} }
/** /**
* @param float $left * @param string $left
*/ */
public function setLeft($left) public function setLeft($left)
{ {
@@ -113,7 +121,7 @@ class Budget
} }
/** /**
* @return float * @return string
*/ */
public function getOverspent() public function getOverspent()
{ {
@@ -121,15 +129,15 @@ class Budget
} }
/** /**
* @param float $overspent * @param string $overspent
*/ */
public function setOverspent($overspent) public function setOverspent($overspent)
{ {
$this->overspent = $overspent; $this->overspent = strval(round($overspent, 2));
} }
/** /**
* @return float * @return string
*/ */
public function getSpent() public function getSpent()
{ {
@@ -137,11 +145,11 @@ class Budget
} }
/** /**
* @param float $spent * @param string $spent
*/ */
public function setSpent($spent) public function setSpent($spent)
{ {
$this->spent = $spent; $this->spent = strval(round($spent, 2));
} }

View File

@@ -17,16 +17,14 @@ class BudgetLine
/** @var BudgetModel */ /** @var BudgetModel */
protected $budget; protected $budget;
/** @var LimitRepetition */
protected $repetition;
/** @var float */ /** @var float */
protected $budgeted = 0; protected $budgeted = 0;
/** @var float */ /** @var float */
protected $left = 0; protected $left = 0;
/** @var float */ /** @var float */
protected $overspent = 0; protected $overspent = 0;
/** @var LimitRepetition */
protected $repetition;
/** @var float */ /** @var float */
protected $spent = 0; protected $spent = 0;
@@ -94,22 +92,6 @@ class BudgetLine
$this->overspent = $overspent; $this->overspent = $overspent;
} }
/**
* @return float
*/
public function getSpent()
{
return $this->spent;
}
/**
* @param float $spent
*/
public function setSpent($spent)
{
$this->spent = $spent;
}
/** /**
* @return LimitRepetition * @return LimitRepetition
*/ */
@@ -126,5 +108,21 @@ class BudgetLine
$this->repetition = $repetition; $this->repetition = $repetition;
} }
/**
* @return float
*/
public function getSpent()
{
return $this->spent;
}
/**
* @param float $spent
*/
public function setSpent($spent)
{
$this->spent = $spent;
}
} }

View File

@@ -24,8 +24,8 @@ class Category
/** @var Collection */ /** @var Collection */
protected $categories; protected $categories;
/** @var float */ /** @var string */
protected $total = 0; protected $total = '0';
/** /**
* *
@@ -50,7 +50,9 @@ class Category
*/ */
public function addTotal($add) public function addTotal($add)
{ {
$this->total += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
} }
/** /**
@@ -69,11 +71,11 @@ class Category
} }
/** /**
* @return float * @return string
*/ */
public function getTotal() public function getTotal()
{ {
return $this->total; return strval(round($this->total, 2));
} }

View File

@@ -17,8 +17,8 @@ class Expense
{ {
/** @var Collection */ /** @var Collection */
protected $expenses; protected $expenses;
/** @var float */ /** @var string */
protected $total; protected $total = '0';
/** /**
* *
@@ -37,14 +37,15 @@ class Expense
$accountId = $entry->account_id; $accountId = $entry->account_id;
if (!$this->expenses->has($accountId)) { if (!$this->expenses->has($accountId)) {
$newObject = new stdClass; $newObject = new stdClass;
$newObject->amount = floatval($entry->amount); $newObject->amount = strval(round($entry->amount, 2));
$newObject->name = $entry->name; $newObject->name = $entry->name;
$newObject->count = 1; $newObject->count = 1;
$newObject->id = $accountId; $newObject->id = $accountId;
$this->expenses->put($accountId, $newObject); $this->expenses->put($accountId, $newObject);
} else { } else {
$existing = $this->expenses->get($accountId); bcscale(2);
$existing->amount += floatval($entry->amount); $existing = $this->expenses->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->count++; $existing->count++;
$this->expenses->put($accountId, $existing); $this->expenses->put($accountId, $existing);
} }
@@ -55,7 +56,9 @@ class Expense
*/ */
public function addToTotal($add) public function addToTotal($add)
{ {
$this->total += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
} }
/** /**
@@ -73,10 +76,10 @@ class Expense
} }
/** /**
* @return float * @return string
*/ */
public function getTotal() public function getTotal()
{ {
return $this->total; return strval(round($this->total, 2));
} }
} }

View File

@@ -38,14 +38,15 @@ class Income
$accountId = $entry->account_id; $accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) { if (!$this->incomes->has($accountId)) {
$newObject = new stdClass; $newObject = new stdClass;
$newObject->amount = floatval($entry->amount); $newObject->amount = strval(round($entry->amount, 2));
$newObject->name = $entry->name; $newObject->name = $entry->name;
$newObject->count = 1; $newObject->count = 1;
$newObject->id = $accountId; $newObject->id = $accountId;
$this->incomes->put($accountId, $newObject); $this->incomes->put($accountId, $newObject);
} else { } else {
$existing = $this->incomes->get($accountId); bcscale(2);
$existing->amount += floatval($entry->amount); $existing = $this->incomes->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->count++; $existing->count++;
$this->incomes->put($accountId, $existing); $this->incomes->put($accountId, $existing);
} }
@@ -56,7 +57,9 @@ class Income
*/ */
public function addToTotal($add) public function addToTotal($add)
{ {
$this->total += floatval($add); $add = strval(round($add, 2));
bcscale(2);
$this->total = bcadd($this->total, $add);
} }
/** /**
@@ -78,7 +81,7 @@ class Income
*/ */
public function getTotal() public function getTotal()
{ {
return $this->total; return strval(round($this->total, 2));
} }

View File

@@ -34,6 +34,7 @@ class ReportHelper implements ReportHelperInterface
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @param ReportQueryInterface $query * @param ReportQueryInterface $query
* *
*/ */
@@ -64,11 +65,13 @@ class ReportHelper implements ReportHelperInterface
$diff = 0; $diff = 0;
// remove cash account, if any: // remove cash account, if any:
$accounts =$accounts->filter(function(Account $account) { $accounts = $accounts->filter(
if($account->accountType->type != 'Cash account') { function (Account $account) {
return $account; if ($account->accountType->type != 'Cash account') {
} return $account;
}); }
} // @codeCoverageIgnore
);
// summarize: // summarize:
foreach ($accounts as $account) { foreach ($accounts as $account) {

View File

@@ -5,12 +5,10 @@ namespace FireflyIII\Helpers\Report;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt; use Crypt;
use DB;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Steam; use Steam;
@@ -74,7 +72,7 @@ class ReportQuery implements ReportQueryInterface
if ($journal->amount != 0) { if ($journal->amount != 0) {
return $journal; return $journal;
} }
} } // @codeCoverageIgnore
); );
return $data; return $data;
@@ -138,7 +136,6 @@ class ReportQuery implements ReportQueryInterface
* This method returns all "income" journals in a certain period, which are both transfers from a shared account * This method returns all "income" journals in a certain period, which are both transfers from a shared account
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does * and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
* not group and returns different fields. * not group and returns different fields.
* *
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
@@ -191,7 +188,7 @@ class ReportQuery implements ReportQueryInterface
if ($journal->amount != 0) { if ($journal->amount != 0) {
return $journal; return $journal;
} }
} } // @codeCoverageIgnore
); );
return $data; return $data;
@@ -237,13 +234,11 @@ class ReportQuery implements ReportQueryInterface
Auth::user()->transactionjournals() Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.amount', '<', 0)
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->where('transactions.account_id', $account->id) ->where('transactions.account_id', $account->id)
->before($end) ->before($end)
->after($start) ->after($start)
->whereNull('budget_transaction_journal.budget_id') ->whereNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])->sum('amount')
->sum('transactions.amount')
); );
} }

View File

@@ -22,7 +22,7 @@ use View;
class AccountController extends Controller class AccountController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -36,6 +36,8 @@ class PasswordController extends Controller
* @param \Illuminate\Contracts\Auth\Guard $auth * @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
* *
* @codeCoverageIgnore
*
*/ */
public function __construct(Guard $auth, PasswordBroker $passwords) public function __construct(Guard $auth, PasswordBroker $passwords)
{ {

View File

@@ -23,7 +23,7 @@ class BillController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -24,7 +24,7 @@ class BudgetController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -21,7 +21,7 @@ class CategoryController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -24,7 +24,7 @@ abstract class Controller extends BaseController
protected $monthFormat; protected $monthFormat;
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -23,7 +23,7 @@ class CurrencyController extends Controller
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -6,6 +6,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input; use Input;
use Preferences; use Preferences;
use Redirect; use Redirect;
use Route;
use Session; use Session;
use Steam; use Steam;
@@ -87,5 +88,78 @@ class HomeController extends Controller
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts')); return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
} }
/**
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function routes()
{
$directory = '/vagrant_data/Sites/firefly-iii-help';
$languages = array_keys(Config::get('firefly.lang'));
$routes = [];
$ignored = [
'debugbar.openhandler', 'debugbar.assets.css', 'debugbar.assets.js', 'register', 'routes', 'daterange',
'flush', 'delete-account-post', 'change-password-post', 'logout', 'login', 'tags.hideTagHelp',
'budgets.postIncome', 'flush'
];
$ignoreMatch = ['.store', '.update', '.destroy', 'json.'];
$routeCollection = Route::getRoutes();
/** @var \Illuminate\Routing\Route $object */
foreach ($routeCollection as $object) {
// get name:
$name = $object->getName();
// has name and not in ignore list?
if (strlen($name) > 0 && !in_array($name, $ignored)) {
// not in ignoreMatch?
$continue = true;
foreach ($ignoreMatch as $ignore) {
$match = strpos($name, $ignore);
if (!($match === false)) {
$continue = false;
}
}
unset($ignore, $match);
if ($continue) {
$routes[] = $name;
// check all languages:
foreach ($languages as $lang) {
$file = $directory . '/' . $lang . '/' . $name . '.md';
if (!file_exists($file)) {
touch($file);
echo $name . '<br />';
}
}
}
}
}
// loop directories with language file.
// tag the ones not in the list of approved routes.
foreach ($languages as $lang) {
$dir = $directory . '/' . $lang;
$set = scandir($dir);
foreach ($set as $entry) {
if ($entry != '.' && $entry != '..') {
$name = str_replace('.md', '', $entry);
if (!in_array($name, $routes)) {
$file = $dir . '/' . $entry;
unlink($file);
}
}
}
}
echo 'Done!';
}
} }

View File

@@ -26,7 +26,7 @@ class PiggyBankController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -17,7 +17,7 @@ class PreferencesController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -23,6 +23,8 @@ class ReportController extends Controller
protected $helper; protected $helper;
/** /**
* @codeCoverageIgnore
*
* @param ReportHelperInterface $helper * @param ReportHelperInterface $helper
*/ */
public function __construct(ReportHelperInterface $helper) public function __construct(ReportHelperInterface $helper)

View File

@@ -32,7 +32,7 @@ use View;
class TagController extends Controller class TagController extends Controller
{ {
/** /**
* * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -26,6 +26,7 @@ use View;
class TransactionController extends Controller class TransactionController extends Controller
{ {
/** /**
* @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {

View File

@@ -37,6 +37,7 @@ class Kernel extends HttpKernel
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated', 'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
'range' => 'FireflyIII\Http\Middleware\Range', 'range' => 'FireflyIII\Http\Middleware\Range',
'cleanup' => 'FireflyIII\Http\Middleware\Cleanup',
'reminders' => 'FireflyIII\Http\Middleware\Reminders', 'reminders' => 'FireflyIII\Http\Middleware\Reminders',
'piggybanks' => 'FireflyIII\Http\Middleware\PiggyBanks', 'piggybanks' => 'FireflyIII\Http\Middleware\PiggyBanks',

View File

@@ -0,0 +1,283 @@
<?php namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Session;
/**
* Class Cleanup
*
* @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class Cleanup
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
*
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
$run = env('RUNCLEANUP') == 'true' ? true : false;
$count = 0;
if ($run) {
// encrypt account name
$set = Account::where('encrypted', 0)->take(5)->get();
/** @var Account $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill name
$set = Bill::where('name_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill match
$set = Bill::where('match_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$match = $entry->match;
$entry->match = $match;
$entry->save();
}
unset($set, $entry, $match);
// encrypt budget name
$set = Budget::where('encrypted', 0)->take(5)->get();
/** @var Budget $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt category name
$set = Category::where('encrypted', 0)->take(5)->get();
/** @var Category $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt piggy bank name
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
/** @var PiggyBank $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt transaction journal description
$set = TransactionJournal::where('encrypted', 0)->take(5)->get();
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$count++;
$description = $entry->description;
$entry->description = $description;
$entry->save();
}
unset($set, $entry, $description);
// encrypt reminder metadata
$set = Reminder::where('encrypted', 0)->take(5)->get();
/** @var Reminder $entry */
foreach ($set as $entry) {
$count++;
$metadata = $entry->metadata;
$entry->metadata = $metadata;
$entry->save();
}
unset($set, $entry, $metadata);
// encrypt account virtual balance amount
$set = Account::whereNull('virtual_balance_encrypted')->take(5)->get();
/** @var Account $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount;
$entry->virtual_balance = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt bill amount_min
$set = Bill::whereNull('amount_min_encrypted')->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount_min;
$entry->amount_min = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt bill amount_max
$set = Bill::whereNull('amount_max_encrypted')->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount_max;
$entry->amount_max = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt budget limit amount
$set = BudgetLimit::whereNull('amount_encrypted')->take(5)->get();
/** @var BudgetLimit $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount;
$entry->amount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt limit repetition amount
$set = LimitRepetition::whereNull('amount_encrypted')->take(5)->get();
/** @var LimitRepetition $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount;
$entry->amount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
//encrypt piggy bank event amount
$set = PiggyBankEvent::whereNull('amount_encrypted')->take(5)->get();
/** @var PiggyBankEvent $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount;
$entry->amount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt piggy bank repetition currentamount
$set = PiggyBankRepetition::whereNull('currentamount_encrypted')->take(5)->get();
/** @var PiggyBankRepetition $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->currentamount;
$entry->currentamount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
// encrypt piggy bank targetamount
$set = PiggyBank::whereNull('targetamount_encrypted')->take(5)->get();
/** @var PiggyBank $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->targetamount;
$entry->targetamount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
//encrypt preference name
$set = Preference::whereNull('name_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
//encrypt preference data (add field)
$set = Preference::whereNull('data_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$data = $entry->data;
$entry->data = $data;
$entry->save();
}
unset($set, $entry, $data);
// encrypt transaction amount
$set = Transaction::whereNull('amount_encrypted')->take(5)->get();
/** @var Transaction $entry */
foreach ($set as $entry) {
$count++;
$amount = $entry->amount;
$entry->amount = $amount;
$entry->save();
}
unset($set, $entry, $amount);
}
if ($count == 0 && $run) {
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
}
return $next($request);
}
}

View File

@@ -1,7 +1,6 @@
<?php <?php
use Carbon\Carbon; use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator; use DaveJamesMiller\Breadcrumbs\Generator;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
@@ -71,7 +70,7 @@ Breadcrumbs::register(
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->push(trans('breadcrumbs.edit_'.$what.'_account', ['name' => e($account->name)]), route('accounts.edit', $account->id)); $breadcrumbs->push(trans('breadcrumbs.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', $account->id));
} }
); );

View File

@@ -193,13 +193,14 @@ Route::controllers(
] ]
); );
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
/** /**
* Home Controller * Home Controller
*/ */
Route::group( Route::group(
['middleware' => ['auth', 'range', 'reminders', 'piggybanks']], function () { ['middleware' => ['auth', 'range', 'reminders', 'piggybanks']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']); Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index', 'middleware' => 'cleanup']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']); Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']); Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);

View File

@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use App;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@@ -18,6 +17,7 @@ class Account extends Model
use SoftDeletes, ValidatingTrait; use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance']; protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance'];
protected $hidden = ['virtual_balance_encrypted', 'encrypted'];
protected $rules protected $rules
= [ = [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
@@ -50,12 +50,6 @@ class Account extends Model
} }
// create it! // create it!
$account = Account::create($fields); $account = Account::create($fields);
if (is_null($account->id)) {
// could not create account:
App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors()));
}
return $account; return $account;
@@ -117,6 +111,8 @@ class Account extends Model
* *
* @param $fieldName * @param $fieldName
* *
* @codeCoverageIgnore
*
* @return string|null * @return string|null
*/ */
public function getMeta($fieldName) public function getMeta($fieldName)
@@ -145,9 +141,7 @@ class Account extends Model
return Crypt::decrypt($value); return Crypt::decrypt($value);
} }
// @codeCoverageIgnoreStart
return $value; return $value;
// @codeCoverageIgnoreEnd
} }
/** /**
@@ -203,6 +197,16 @@ class Account extends Model
$this->attributes['encrypted'] = true; $this->attributes['encrypted'] = true;
} }
/**
* @param $value
*
* @codeCoverageIgnore
*/
public function setVirtualBalanceAttribute($value)
{
$this->attributes['virtual_balance'] = strval(round($value, 2));
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany

View File

@@ -4,6 +4,7 @@ use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* @codeCoverageIgnore
* Class Bill * Class Bill
* *
* @package FireflyIII\Models * @package FireflyIII\Models
@@ -14,6 +15,8 @@ class Bill extends Model
protected $fillable protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',]; = ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/** /**
* @return array * @return array
*/ */
@@ -34,9 +37,7 @@ class Bill extends Model
return Crypt::decrypt($value); return Crypt::decrypt($value);
} }
// @codeCoverageIgnoreStart
return $value; return $value;
// @codeCoverageIgnoreEnd
} }
/** /**
@@ -51,9 +52,23 @@ class Bill extends Model
return Crypt::decrypt($value); return Crypt::decrypt($value);
} }
// @codeCoverageIgnoreStart
return $value; return $value;
// @codeCoverageIgnoreEnd }
/**
* @param $value
*/
public function setAmountMaxAttribute($value)
{
$this->attributes['amount_max'] = strval(round($value, 2));
}
/**
* @param $value
*/
public function setAmountMinAttribute($value)
{
$this->attributes['amount_min'] = strval(round($value, 2));
} }
/** /**

View File

@@ -15,7 +15,8 @@ class Budget extends Model
use SoftDeletes; use SoftDeletes;
protected $fillable = ['user_id', 'name']; protected $fillable = ['user_id', 'name', 'active'];
protected $hidden = ['encrypted'];
/** /**
* *
@@ -46,9 +47,7 @@ class Budget extends Model
return Crypt::decrypt($value); return Crypt::decrypt($value);
} }
// @codeCoverageIgnoreStart
return $value; return $value;
// @codeCoverageIgnoreEnd
} }
/** /**

View File

@@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Model;
class BudgetLimit extends Model class BudgetLimit extends Model
{ {
protected $hidden = ['amount_encrypted'];
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
@@ -35,4 +37,12 @@ class BudgetLimit extends Model
return $this->hasMany('FireflyIII\Models\LimitRepetition'); return $this->hasMany('FireflyIII\Models\LimitRepetition');
} }
/**
* @param $value
*/
public function setAmountAttribute($value)
{
$this->attributes['amount'] = strval(round($value, 2));
}
} }

View File

@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use App;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,24 +15,7 @@ class Category extends Model
use SoftDeletes; use SoftDeletes;
protected $fillable = ['user_id', 'name']; protected $fillable = ['user_id', 'name'];
protected $hidden = ['encrypted'];
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
/** /**
* @param array $fields * @param array $fields
@@ -59,11 +41,6 @@ class Category extends Model
} }
// create it! // create it!
$category = Category::create($fields); $category = Category::create($fields);
if (is_null($category->id)) {
// could not create account:
App::abort(500, 'Could not create new category with data: ' . json_encode($fields));
}
return $category; return $category;
@@ -71,22 +48,11 @@ class Category extends Model
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return array
*/ */
public function user() public function getDates()
{ {
return $this->belongsTo('FireflyIII\User'); return ['created_at', 'updated_at', 'deleted_at'];
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
} }
/** /**
@@ -106,4 +72,33 @@ class Category extends Model
return $value; return $value;
} }
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
} }

View File

@@ -1,19 +1,20 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use Auth;
use DB;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* Class LimitRepetition * Class LimitRepetition
* *
* @codeCoverageIgnore
*
* @package FireflyIII\Models * @package FireflyIII\Models
*/ */
class LimitRepetition extends Model class LimitRepetition extends Model
{ {
protected $hidden = ['amount_encrypted'];
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function budgetLimit() public function budgetLimit()
@@ -22,7 +23,6 @@ class LimitRepetition extends Model
} }
/** /**
* @codeCoverageIgnore
* @return array * @return array
*/ */
public function getDates() public function getDates()
@@ -31,24 +31,11 @@ class LimitRepetition extends Model
} }
/** /**
* @return float * @param $value
*/ */
public function spentInRepetition() public function setAmountAttribute($value)
{ {
$sum = DB::table('transactions') $this->attributes['amount'] = strval(round($value, 2));
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
->where('transaction_journals.user_id', Auth::user()->id)
->whereNull('transactions.deleted_at')
->where('transactions.amount', '>', 0)
->where('limit_repetitions.id', '=', $this->id)
->sum('transactions.amount');
return floatval($sum);
} }
} }

View File

@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class PiggyBank * Class PiggyBank
* *
* @codeCoverageIgnore
*
* @package FireflyIII\Models * @package FireflyIII\Models
*/ */
class PiggyBank extends Model class PiggyBank extends Model
@@ -14,10 +16,10 @@ class PiggyBank extends Model
use SoftDeletes; use SoftDeletes;
protected $fillable protected $fillable
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me']; = ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
protected $hidden = ['targetamount_encrypted', 'encrypted'];
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function account() public function account()
@@ -45,7 +47,6 @@ class PiggyBank extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function piggyBankRepetitions() public function piggyBankRepetitions()
@@ -54,7 +55,6 @@ class PiggyBank extends Model
} }
/** /**
* @codeCoverageIgnore
* @return array * @return array
*/ */
public function getDates() public function getDates()
@@ -63,48 +63,6 @@ class PiggyBank extends Model
} }
/** /**
* @codeCoverageIgnore
*
* @param $value
*
* @return int
*/
public function getRemindMeAttribute($value)
{
return intval($value) == 1;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
{
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
{
return $this->morphMany('FireflyIII\Models\Reminder', 'remindersable');
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -117,8 +75,51 @@ class PiggyBank extends Model
return Crypt::decrypt($value); return Crypt::decrypt($value);
} }
// @codeCoverageIgnoreStart
return $value; return $value;
// @codeCoverageIgnoreEnd }
/**
*
* @param $value
*
* @return int
*/
public function getRemindMeAttribute($value)
{
return intval($value) == 1;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
{
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
{
return $this->morphMany('FireflyIII\Models\Reminder', 'remindersable');
}
/**
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @param $value
*/
public function setTargetamountAttribute($value)
{
$this->attributes['targetamount'] = strval(round($value, 2));
} }
} }

View File

@@ -6,12 +6,14 @@ use Illuminate\Database\Eloquent\Model;
* Class PiggyBankEvent * Class PiggyBankEvent
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @package FireflyIII\Models * @package FireflyIII\Models
*/ */
class PiggyBankEvent extends Model class PiggyBankEvent extends Model
{ {
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount']; protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
protected $hidden = ['amount_encrypted'];
/** /**
* @return array * @return array
@@ -29,6 +31,14 @@ class PiggyBankEvent extends Model
return $this->belongsTo('FireflyIII\Models\PiggyBank'); return $this->belongsTo('FireflyIII\Models\PiggyBank');
} }
/**
* @param $value
*/
public function setAmountAttribute($value)
{
$this->attributes['amount'] = strval(round($value, 2));
}
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@@ -14,6 +14,7 @@ class PiggyBankRepetition extends Model
{ {
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount']; protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
protected $hidden = ['currentamount_encrypted'];
/** /**
* @return array * @return array
@@ -66,4 +67,12 @@ class PiggyBankRepetition extends Model
); );
} }
/**
* @param $value
*/
public function setCurrentamountAttribute($value)
{
$this->attributes['currentamount'] = strval(round($value, 2));
}
} }

View File

@@ -1,5 +1,6 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
@@ -12,6 +13,7 @@ class Preference extends Model
{ {
protected $fillable = ['user_id', 'data', 'name']; protected $fillable = ['user_id', 'data', 'name'];
protected $hidden = ['data_encrypted', 'name_encrypted'];
/** /**
* @param $value * @param $value
@@ -20,7 +22,12 @@ class Preference extends Model
*/ */
public function getDataAttribute($value) public function getDataAttribute($value)
{ {
return json_decode($value); if (is_null($this->data_encrypted)) {
return json_decode($value);
}
$data = Crypt::decrypt($this->data_encrypted);
return json_decode($data);
} }
/** /**
@@ -31,12 +38,37 @@ class Preference extends Model
return ['created_at', 'updated_at']; return ['created_at', 'updated_at'];
} }
/**
* @param $value
*
* @return float|int
*/
public function getNameAttribute($value)
{
if (is_null($this->name_encrypted)) {
return $value;
}
$value = Crypt::decrypt($this->name_encrypted);
return $value;
}
/** /**
* @param $value * @param $value
*/ */
public function setDataAttribute($value) public function setDataAttribute($value)
{ {
$this->attributes['data'] = json_encode($value); $this->attributes['data'] = '';//json_encode($value);
$this->attributes['data_encrypted'] = Crypt::encrypt(json_encode($value));
}
/**
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name_encrypted'] = Crypt::encrypt($value);
$this->attributes['name'] = $value;
} }
/** /**

View File

@@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class Reminder * Class Reminder
* *
* @codeCoverageIgnore
*
* @package FireflyIII\Models * @package FireflyIII\Models
*/ */
class Reminder extends Model class Reminder extends Model
@@ -15,9 +17,9 @@ class Reminder extends Model
protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',]; protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];
protected $hidden = ['encrypted'];
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -29,7 +31,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* @return array * @return array
*/ */
public function getDates() public function getDates()
@@ -38,7 +39,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -54,7 +54,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -66,7 +65,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphTo * @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/ */
public function remindersable() public function remindersable()
@@ -75,7 +73,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param Carbon $start * @param Carbon $start
@@ -89,7 +86,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* *
@@ -104,7 +100,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -115,7 +110,6 @@ class Reminder extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user()

View File

@@ -2,7 +2,6 @@
namespace FireflyIII\Models; namespace FireflyIII\Models;
use App;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
@@ -57,12 +56,6 @@ class Tag extends Model
$fields['tagMode'] = 'nothing'; $fields['tagMode'] = 'nothing';
$fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : ''; $fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
$tag = Tag::create($fields); $tag = Tag::create($fields);
if (is_null($tag->id)) {
// could not create account:
App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors()));
}
return $tag; return $tag;

View File

@@ -16,6 +16,7 @@ class Transaction extends Model
{ {
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount']; protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount'];
protected $hidden = ['encrypted'];
protected $rules protected $rules
= [ = [
'account_id' => 'required|exists:accounts,id', 'account_id' => 'required|exists:accounts,id',
@@ -33,6 +34,24 @@ class Transaction extends Model
return $this->belongsTo('FireflyIII\Models\Account'); return $this->belongsTo('FireflyIII\Models\Account');
} }
/**
* @param $value
*
* @return float|int
*/
public function getAmountAttribute($value)
{
return $value;
}
/**
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
/** /**
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param Carbon $date * @param Carbon $date
@@ -56,11 +75,11 @@ class Transaction extends Model
} }
/** /**
* @return array * @param $value
*/ */
public function getDates() public function setAmountAttribute($value)
{ {
return ['created_at', 'updated_at', 'deleted_at']; $this->attributes['amount'] = strval(round($value, 2));
} }
/** /**

View File

@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
/** /**
@@ -19,9 +18,9 @@ class TransactionJournal extends Model
use SoftDeletes, ValidatingTrait; use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted']; protected $fillable = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted'];
protected $hidden = ['encrypted'];
protected $rules protected $rules
= [ = [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
'transaction_type_id' => 'required|exists:transaction_types,id', 'transaction_type_id' => 'required|exists:transaction_types,id',
'bill_id' => 'exists:bills,id', 'bill_id' => 'exists:bills,id',
@@ -60,15 +59,15 @@ class TransactionJournal extends Model
} }
/** /**
* @return float * @return string
*/ */
public function getActualAmountAttribute() public function getActualAmountAttribute()
{ {
$amount = 0; $amount = '0';
/** @var Transaction $t */ /** @var Transaction $t */
foreach ($this->transactions as $t) { foreach ($this->transactions as $t) {
if ($t->amount > 0) { if ($t->amount > 0) {
$amount = floatval($t->amount); $amount = $t->amount;
} }
} }
@@ -80,11 +79,12 @@ class TransactionJournal extends Model
*/ */
public function getAmountAttribute() public function getAmountAttribute()
{ {
$amount = 0; $amount = '0';
bcscale(2);
/** @var Transaction $t */ /** @var Transaction $t */
foreach ($this->transactions as $t) { foreach ($this->transactions as $t) {
if ($t->amount > 0) { if ($t->amount > 0) {
$amount = floatval($t->amount); $amount = $t->amount;
} }
} }
@@ -94,16 +94,16 @@ class TransactionJournal extends Model
if ($this->tags->count() == 0) { if ($this->tags->count() == 0) {
return $amount; return $amount;
} }
// if journal is part of advancePayment AND journal is a withdrawal, // if journal is part of advancePayment AND journal is a withdrawal,
// then journal is being repaid by other journals, so the actual amount will lower: // then journal is being repaid by other journals, so the actual amount will lower:
/** @var Tag $advancePayment */ /** @var Tag $advancePayment */
$advancePayment = $this->tags()->where('tagMode', 'advancePayment')->first(); $advancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($advancePayment && $this->transactionType->type == 'Withdrawal') { if ($advancePayment && $this->transactionType->type == 'Withdrawal') {
// loop other deposits, remove from our amount. // loop other deposits, remove from our amount.
$others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get(); $others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get();
foreach ($others as $other) { foreach ($others as $other) {
$amount -= $other->actualAmount; $amount = bcsub($amount, $other->actualAmount);
} }
return $amount; return $amount;
@@ -112,25 +112,24 @@ class TransactionJournal extends Model
// if this journal is part of an advancePayment AND the journal is a deposit, // if this journal is part of an advancePayment AND the journal is a deposit,
// then the journal amount is correcting a withdrawal, and the amount is zero: // then the journal amount is correcting a withdrawal, and the amount is zero:
if ($advancePayment && $this->transactionType->type == 'Deposit') { if ($advancePayment && $this->transactionType->type == 'Deposit') {
return 0; return '0';
} }
// is balancing act? // is balancing act?
$balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first(); $balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
if ($balancingAct) {
// this is the transfer
if ($balancingAct) {
// this is the expense: // this is the expense:
if ($this->transactionType->type == 'Withdrawal') { if ($this->transactionType->type == 'Withdrawal') {
$transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first(); $transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first();
if ($transfer) { if ($transfer) {
$amount -= $transfer->actualAmount; $amount = bcsub($amount, $transfer->actualAmount);
return $amount; return $amount;
} }
} } // @codeCoverageIgnore
} } // @codeCoverageIgnore
return $amount; return $amount;
} }
@@ -181,16 +180,16 @@ class TransactionJournal extends Model
*/ */
public function getCorrectedActualAmountAttribute() public function getCorrectedActualAmountAttribute()
{ {
$amount = 0; $amount = '0';
$type = $this->transactionType->type; $type = $this->transactionType->type;
/** @var Transaction $t */ /** @var Transaction $t */
foreach ($this->transactions as $t) { foreach ($this->transactions as $t) {
if ($t->amount > 0 && $type != 'Withdrawal') { if ($t->amount > 0 && $type != 'Withdrawal') {
$amount = floatval($t->amount); $amount = $t->amount;
break; break;
} }
if ($t->amount < 0 && $type == 'Withdrawal') { if ($t->amount < 0 && $type == 'Withdrawal') {
$amount = floatval($t->amount); $amount = $t->amount;
break; break;
} }
} }
@@ -223,6 +222,21 @@ class TransactionJournal extends Model
return $value; return $value;
} }
/**
* @return Account
*/
public function getDestinationAccountAttribute()
{
/** @var Transaction $transaction */
foreach ($this->transactions()->get() as $transaction) {
if (floatval($transaction->amount) > 0) {
return $transaction->account;
}
}
return $this->transactions()->first()->account;
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -273,24 +287,6 @@ class TransactionJournal extends Model
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00')); return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
} }
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param $amount
*/
public function scopeLessThan(EloquentBuilder $query, $amount)
{
if (is_null($this->joinedTransactions)) {
$query->leftJoin(
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
);
$this->joinedTransactions = true;
}
$query->where('transactions.amount', '<=', $amount);
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@@ -304,24 +300,6 @@ class TransactionJournal extends Model
return $query->where('date', '=', $date->format('Y-m-d')); return $query->where('date', '=', $date->format('Y-m-d'));
} }
/**
* Returns the account to which the money was moved.
*
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Account $account
*/
public function scopeToAccountIs(EloquentBuilder $query, Account $account)
{
$query->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
}
);
$query->where('transactions.account_id', $account->id);
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* *

View File

@@ -287,7 +287,7 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function getTransfersInRange(Account $account, Carbon $start, Carbon $end) public function getTransfersInRange(Account $account, Carbon $start, Carbon $end)
{ {
return TransactionJournal::whereIn( $set = TransactionJournal::whereIn(
'id', function (Builder $q) use ($account, $start, $end) { 'id', function (Builder $q) use ($account, $start, $end) {
$q->select('transaction_journals.id') $q->select('transaction_journals.id')
->from('transactions') ->from('transactions')
@@ -297,11 +297,19 @@ class AccountRepository implements AccountRepositoryInterface
->where('transaction_journals.user_id', Auth::user()->id) ->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('transactions.amount', '>', 0)
->where('transaction_types.type', 'Transfer'); ->where('transaction_types.type', 'Transfer');
} }
)->get(); )->get();
$filtered = $set->filter(
function (TransactionJournal $journal) use ($account) {
if ($journal->destination_account->id == $account->id) {
return $journal;
}
} // @codeCoverageIgnore
);
return $filtered;
} }
/** /**

View File

@@ -10,7 +10,6 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Navigation; use Navigation;
@@ -108,16 +107,10 @@ class BillRepository implements BillRepositoryInterface
public function getJournals(Bill $bill) public function getJournals(Bill $bill)
{ {
return $bill->transactionjournals()->withRelevantData() return $bill->transactionjournals()->withRelevantData()
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.amount', '>', 0);
}
)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->get(['transaction_journals.*', 'transactions.amount']); ->get(['transaction_journals.*']);
} }
/** /**

View File

@@ -250,9 +250,8 @@ class BudgetRepository implements BudgetRepositoryInterface
) )
->after($start) ->after($start)
->before($end) ->before($end)
->lessThan(0)
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->sum('transactions.amount'); ->get(['transaction_journals.*'])->sum('amount');
return floatval($noBudgetSet) * -1; return floatval($noBudgetSet) * -1;
} }
@@ -269,13 +268,13 @@ class BudgetRepository implements BudgetRepositoryInterface
{ {
if ($shared === true) { if ($shared === true) {
// get everything: // get everything:
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->lessThan(0)->get(['transaction_journals.*'])->sum('amount')); $sum = floatval($budget->transactionjournals()->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount'));
} else { } else {
// get all journals in this month where the asset account is NOT shared. // get all journals in this month where the asset account is NOT shared.
$sum = $budget->transactionjournals() $sum = $budget->transactionjournals()
->before($end) ->before($end)
->after($start) ->after($start)
->lessThan(0) ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin( ->leftJoin(
'account_meta', function (JoinClause $join) { 'account_meta', function (JoinClause $join) {
@@ -310,7 +309,6 @@ class BudgetRepository implements BudgetRepositoryInterface
} }
/** /**
* @param Budget $budget * @param Budget $budget
* @param array $data * @param array $data

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Repositories\Category;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt; use Crypt;
use DB;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
@@ -86,7 +85,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$result[$categoryId]['sum'] += floatval($entry->amount); $result[$categoryId]['sum'] += floatval($entry->amount);
} else { } else {
$isEncrypted = intval($entry->category_encrypted) == 1 ? true : false; $isEncrypted = intval($entry->category_encrypted) == 1 ? true : false;
$name = strlen($entry->name) == 0 ? trans('firefly.noCategory') : $entry->name; $name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name;
$name = $isEncrypted ? Crypt::decrypt($name) : $name; $name = $isEncrypted ? Crypt::decrypt($name) : $name;
$result[$categoryId] = [ $result[$categoryId] = [
'name' => $name, 'name' => $name,
@@ -202,7 +201,7 @@ class CategoryRepository implements CategoryRepositoryInterface
->before($end) ->before($end)
->after($start) ->after($start)
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->lessThan(0) ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin( ->leftJoin(
'account_meta', function (JoinClause $join) { 'account_meta', function (JoinClause $join) {

View File

@@ -76,15 +76,20 @@ class JournalRepository implements JournalRepositoryInterface
*/ */
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction) public function getAmountBefore(TransactionJournal $journal, Transaction $transaction)
{ {
return floatval( $set = $transaction->account->transactions()->leftJoin(
$transaction->account->transactions()->leftJoin( 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' )
) ->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d')) ->where('transaction_journals.order', '>=', $journal->order)
->where('transaction_journals.order', '>=', $journal->order) ->where('transaction_journals.id', '!=', $journal->id)
->where('transaction_journals.id', '!=', $journal->id) ->get(['transactions.*']);
->sum('transactions.amount') $sum = 0;
); foreach ($set as $entry) {
$sum += $entry->amount;
}
return $sum;
} }
/** /**

View File

@@ -78,9 +78,13 @@ class TagRepository implements TagRepositoryInterface
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($tags as $tag) { foreach ($tags as $tag) {
$transfer = $tag->transactionjournals()->after($start)->before($end)->toAccountIs($account)->transactionTypes(['Transfer'])->first(); $journals = $tag->transactionjournals()->after($start)->before($end)->transactionTypes(['Transfer'])->get(['transaction_journals.*']);
if ($transfer) {
$amount += $transfer->amount; /** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if ($journal->destination_account->id == $account->id) {
$amount += $journal->amount;
}
} }
} }

View File

@@ -34,16 +34,21 @@ class Steam
$firstDate = is_null($firstDateObject) ? clone $date : new Carbon($firstDateObject->date); $firstDate = is_null($firstDateObject) ? clone $date : new Carbon($firstDateObject->date);
$date = $date < $firstDate ? $firstDate : $date; $date = $date < $firstDate ? $firstDate : $date;
$balance = floatval( bcscale(2);
$account->transactions()->leftJoin( $set = $account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount') )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->get(['transactions.*']);
); $balance = '0';
if (!$ignoreVirtualBalance) { foreach ($set as $entry) {
$balance += floatval($account->virtual_balance); $balance = bcadd($balance, $entry->amount);
} }
return $balance; if (!$ignoreVirtualBalance) {
$balance = bcadd($balance, $account->virtual_balance);
//$balance += floatval($account->virtual_balance);
}
return round($balance, 2);
} }
/** /**

View File

@@ -3,7 +3,6 @@
namespace FireflyIII\Support\Twig; namespace FireflyIII\Support\Twig;
use Auth; use Auth;
use DB;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use Twig_Extension; use Twig_Extension;
use Twig_SimpleFunction; use Twig_SimpleFunction;
@@ -20,25 +19,6 @@ class Budget extends Twig_Extension
*/ */
public function getFunctions() public function getFunctions()
{ {
$functions[] = new Twig_SimpleFunction(
'spentInRepetition', function (LimitRepetition $repetition) {
$sum = DB::table('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('transaction_journals.date', '>=', $repetition->startdate->format('Y-m-d'))
->where('transaction_journals.date', '<=', $repetition->enddate->format('Y-m-d'))
->where('transaction_journals.user_id', Auth::user()->id)
->whereNull('transactions.deleted_at')
->where('transactions.amount', '>', 0)
->where('limit_repetitions.id', '=', $repetition->id)
->sum('transactions.amount');
return floatval($sum);
}
);
$functions[] = new Twig_SimpleFunction( $functions[] = new Twig_SimpleFunction(
'spentInRepetitionCorrected', function (LimitRepetition $repetition) { 'spentInRepetitionCorrected', function (LimitRepetition $repetition) {
$sum $sum

View File

@@ -84,7 +84,7 @@ class Journal extends Twig_Extension
if ($tag->tagMode == 'balancingAct') { if ($tag->tagMode == 'balancingAct') {
// return tag formatted for a "balancing act", even if other // return tag formatted for a "balancing act", even if other
// tags are present. // tags are present.
$amount = App::make('amount')->formatJournal($journal, false); $amount = App::make('amount')->format($journal->actual_amount, false);
return '<a href="' . route('tags.show', $tag->id) . '" class="label label-success" title="' . $amount return '<a href="' . route('tags.show', $tag->id) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>'; . '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>';

View File

@@ -0,0 +1,148 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV3409
*/
class ChangesForV3409 extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// remove decryption, but this will destroy amounts.
Schema::table(
'accounts', function (Blueprint $table) {
$table->dropColumn('virtual_balance_encrypted');
}
);
Schema::table(
'bills', function (Blueprint $table) {
$table->dropColumn('amount_min_encrypted');
$table->dropColumn('amount_max_encrypted');
}
);
Schema::table(
'budget_limits', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'limit_repetitions', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'piggy_bank_events', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
Schema::table(
'piggy_bank_repetitions', function (Blueprint $table) {
$table->dropColumn('currentamount_encrypted');
}
);
Schema::table(
'piggy_banks', function (Blueprint $table) {
$table->dropColumn('targetamount_encrypted');
}
);
Schema::table(
'preferences', function (Blueprint $table) {
$table->dropColumn('name_encrypted');
$table->dropColumn('data_encrypted');
}
);
Schema::table(
'transactions', function (Blueprint $table) {
$table->dropColumn('amount_encrypted');
}
);
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// encrypt account virtual balance:
Schema::table(
'accounts', function (Blueprint $table) {
$table->string('virtual_balance_encrypted')->nullable()->after('virtual_balance');
}
);
// encrypt bill amount_min and amount_max:
Schema::table(
'bills', function (Blueprint $table) {
$table->string('amount_min_encrypted')->nullable()->after('amount_min');
$table->string('amount_max_encrypted')->nullable()->after('amount_max');
}
);
// encrypt budget limit amount
Schema::table(
'budget_limits', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt limit repetition amount
Schema::table(
'limit_repetitions', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt piggy bank event amount
Schema::table(
'piggy_bank_events', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
// encrypt piggy bank repetition currentamount
Schema::table(
'piggy_bank_repetitions', function (Blueprint $table) {
$table->string('currentamount_encrypted')->nullable()->after('currentamount');
}
);
// encrypt piggy bank targetamount
Schema::table(
'piggy_banks', function (Blueprint $table) {
$table->string('targetamount_encrypted')->nullable()->after('targetamount');
}
);
// encrypt preference name (add field)
// encrypt preference data (add field)
Schema::table(
'preferences', function (Blueprint $table) {
$table->text('name_encrypted')->nullable()->after('name');
$table->text('data_encrypted')->nullable()->after('data');
}
);
// encrypt transaction amount
Schema::table(
'transactions', function (Blueprint $table) {
$table->string('amount_encrypted')->nullable()->after('amount');
}
);
}
}

View File

@@ -134,7 +134,9 @@ class TestDataSeeder extends Seeder
$acc_a = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Checking account', 'active' => 1]); $acc_a = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Checking account', 'active' => 1]);
$acc_b = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Savings account', 'active' => 1]); $acc_b = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Savings account', 'active' => 1]);
$acc_c = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1]); $acc_c = Account::create(
['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1, 'virtual_balance' => 123.45]
);
// create account meta: // create account meta:
AccountMeta::create(['account_id' => $acc_a->id, 'name' => 'accountRole', 'data' => 'defaultAsset']); AccountMeta::create(['account_id' => $acc_a->id, 'name' => 'accountRole', 'data' => 'defaultAsset']);
@@ -514,27 +516,6 @@ class TestDataSeeder extends Seeder
return null; return null;
} }
/**
* @param $name
*
* @return PiggyBank|null
*/
protected function findPiggyBank($name)
{
// account
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
/** @var Budget $budget */
foreach (PiggyBank::get() as $piggyBank) {
$account = $piggyBank->account()->first();
if ($piggyBank->name == $name && $user->id == $account->user_id) {
return $piggyBank;
break;
}
}
return null;
}
/** /**
* @param $name * @param $name
* *
@@ -680,5 +661,26 @@ class TestDataSeeder extends Seeder
); );
} }
/**
* @param $name
*
* @return PiggyBank|null
*/
protected function findPiggyBank($name)
{
// account
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
/** @var Budget $budget */
foreach (PiggyBank::get() as $piggyBank) {
$account = $piggyBank->account()->first();
if ($piggyBank->name == $name && $user->id == $account->user_id) {
return $piggyBank;
break;
}
}
return null;
}
} }

View File

@@ -29,8 +29,6 @@ return [
'transactionsWithoutBudgetDate' => 'Expenses without budget in :date', 'transactionsWithoutBudgetDate' => 'Expenses without budget in :date',
'createBudget' => 'New budget', 'createBudget' => 'New budget',
'inactiveBudgets' => 'Inactive budgets', 'inactiveBudgets' => 'Inactive budgets',
'newCategory' => 'New category',
'withoutCategory' => 'Without a category',
'details_for_asset' => 'Details for asset account ":name"', 'details_for_asset' => 'Details for asset account ":name"',
'details_for_expense' => 'Details for expense account ":name"', 'details_for_expense' => 'Details for expense account ":name"',
@@ -53,6 +51,14 @@ return [
'make_new_expense_account' => 'New expense account', 'make_new_expense_account' => 'New expense account',
'make_new_revenue_account' => 'New revenue account', 'make_new_revenue_account' => 'New revenue account',
// categories:
'new_category' => 'New category',
'without_category' => 'Without a category',
'update_category' => 'Wijzig categorie',
'categories' => 'Categories',
'no_category' => '(no category)',
'category' => 'Category',
// new user: // new user:
'welcome' => 'Welcome to Firefly!', 'welcome' => 'Welcome to Firefly!',
'createNewAsset' => 'Create a new asset account to get started. This will allow you to create transactions and start your financial management', 'createNewAsset' => 'Create a new asset account to get started. This will allow you to create transactions and start your financial management',
@@ -94,7 +100,6 @@ return [
'Expense account' => 'Expense account', 'Expense account' => 'Expense account',
'Revenue account' => 'Revenue account', 'Revenue account' => 'Revenue account',
'budgets' => 'Budgets', 'budgets' => 'Budgets',
'categories' => 'Categories',
'tags' => 'Tags', 'tags' => 'Tags',
'reports' => 'Reports', 'reports' => 'Reports',
'transactions' => 'Transactions', 'transactions' => 'Transactions',
@@ -171,9 +176,7 @@ return [
'spent' => 'Spent', 'spent' => 'Spent',
'overspent' => 'Overspent', 'overspent' => 'Overspent',
'left' => 'Left', 'left' => 'Left',
'noCategory' => '(no category)',
'noBudget' => '(no budget)', 'noBudget' => '(no budget)',
'category' => 'Category',
'maxAmount' => 'Maximum amount', 'maxAmount' => 'Maximum amount',
'minAmount' => 'Minumum amount', 'minAmount' => 'Minumum amount',
'billEntry' => 'Current bill entry', 'billEntry' => 'Current bill entry',

View File

@@ -29,8 +29,6 @@ return [
'transactionsWithoutBudgetDate' => 'Uitgaven zonder budget in :date', 'transactionsWithoutBudgetDate' => 'Uitgaven zonder budget in :date',
'createBudget' => 'Maak nieuw budget', 'createBudget' => 'Maak nieuw budget',
'inactiveBudgets' => 'Inactieve budgetten', 'inactiveBudgets' => 'Inactieve budgetten',
'newCategory' => 'Nieuwe categorie',
'withoutCategory' => 'Zonder categorie',
'details_for_asset' => 'Overzicht voor betaalrekening ":name"', 'details_for_asset' => 'Overzicht voor betaalrekening ":name"',
'details_for_expense' => 'Overzicht voor crediteur ":name"', 'details_for_expense' => 'Overzicht voor crediteur ":name"',
@@ -53,6 +51,14 @@ return [
'make_new_expense_account' => 'Nieuwe crediteur', 'make_new_expense_account' => 'Nieuwe crediteur',
'make_new_revenue_account' => 'Nieuwe debiteur', 'make_new_revenue_account' => 'Nieuwe debiteur',
// categories:
'new_category' => 'Nieuwe categorie',
'without_category' => 'Zonder categorie',
'update_category' => 'Wijzig categorie',
'categories' => 'Categorieën',
'no_category' => '(geen categorie)',
'category' => 'Categorie',
// new user: // new user:
'welcome' => 'Welkom bij Firefly!', 'welcome' => 'Welkom bij Firefly!',
'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.', 'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.',
@@ -94,7 +100,6 @@ return [
'Expense account' => 'Crediteur', 'Expense account' => 'Crediteur',
'Revenue account' => 'Debiteur', 'Revenue account' => 'Debiteur',
'budgets' => 'Budgetten', 'budgets' => 'Budgetten',
'categories' => 'Categorieën',
'tags' => 'Tags', 'tags' => 'Tags',
'reports' => 'Overzichten', 'reports' => 'Overzichten',
'transactions' => 'Transacties', 'transactions' => 'Transacties',
@@ -134,10 +139,10 @@ return [
'accountBalances' => 'Rekeningsaldi', 'accountBalances' => 'Rekeningsaldi',
'balanceStartOfYear' => 'Saldo aan het begin van het jaar', 'balanceStartOfYear' => 'Saldo aan het begin van het jaar',
'balanceEndOfYear' => 'Saldo aan het einde van het jaar', 'balanceEndOfYear' => 'Saldo aan het einde van het jaar',
'balanceStartOfMonth' => 'Saldo aan het einde van de maand', 'balanceStartOfMonth' => 'Saldo aan het begin van de maand',
'balanceEndOfMonth' => 'Saldo aan het einde van de maand', 'balanceEndOfMonth' => 'Saldo aan het einde van de maand',
'balanceStart' => 'Saldo aan het einde van de periode', 'balanceStart' => 'Saldo aan het begin van de periode',
'balanceEnd' => 'Saldo aan het einde van de periode', 'balanceEnd' => 'Saldo aan het einde van de periode',
'reportsOwnAccounts' => 'Overzichten voor je eigen betaalrekeningen', 'reportsOwnAccounts' => 'Overzichten voor je eigen betaalrekeningen',
@@ -171,9 +176,7 @@ return [
'spent' => 'Uitgegeven', 'spent' => 'Uitgegeven',
'overspent' => 'Teveel uitgegeven', 'overspent' => 'Teveel uitgegeven',
'left' => 'Over', 'left' => 'Over',
'noCategory' => '(geen categorie)',
'noBudget' => '(geen budget)', 'noBudget' => '(geen budget)',
'category' => 'Categorie',
'maxAmount' => 'Maximaal bedrag', 'maxAmount' => 'Maximaal bedrag',
'minAmount' => 'Minimaal bedrag', 'minAmount' => 'Minimaal bedrag',
'billEntry' => 'Bedrag voor deze rekening', 'billEntry' => 'Bedrag voor deze rekening',

View File

@@ -34,7 +34,7 @@
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<p> <p>
<button type="submit" class="btn btn-lg btn-success"> <button type="submit" class="btn btn-lg btn-success">
Update category {{ 'update_category'|_ }}
</button> </button>
</p> </p>
</div> </div>

View File

@@ -15,7 +15,7 @@
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu pull-right" role="menu"> <ul class="dropdown-menu pull-right" role="menu">
<li><a href="{{ route('categories.create') }}"><i class="fa fa-plus fa-fw"></i> {{ 'newCategory'|_ }}</a></li> <li><a href="{{ route('categories.create') }}"><i class="fa fa-plus fa-fw"></i> {{ 'new_category'|_ }}</a></li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@@ -9,7 +9,7 @@
<tbody> <tbody>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td><a href="{{ route('categories.noCategory') }}"><em>{{ 'withoutCategory'|_ }}</em></a></td> <td><a href="{{ route('categories.noCategory') }}"><em>{{ 'without_category'|_ }}</em></a></td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
{% for category in categories %} {% for category in categories %}

View File

@@ -10,11 +10,11 @@
</tr> </tr>
<tr> <tr>
<td>{{ 'out'|_ }}</td> <td>{{ 'out'|_ }}</td>
<td><span class="text-danger">{{ (expenses.getTotal * -1)|formatAmountPlain }}</span></td> <td><span class="text-danger">{{ (expenses.getTotal)|formatAmountPlain }}</span></td>
</tr> </tr>
<tr> <tr>
<td>{{ 'difference'|_ }}</td> <td>{{ 'difference'|_ }}</td>
<td>{{ (incomes.getTotal + expenses.getTotal)|formatAmount }}</td> <td>{{ (incomes.getTotal + (expenses.getTotal * -1))|formatAmount }}</td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@@ -47,6 +47,9 @@ class AccountControllerTest extends TestCase
} }
/**
*
*/
public function createAccount() public function createAccount()
{ {
if (is_null($this->account)) { if (is_null($this->account)) {
@@ -54,6 +57,9 @@ class AccountControllerTest extends TestCase
} }
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::create
*/
public function testCreate() public function testCreate()
{ {
$pref = FactoryMuffin::create('FireflyIII\Models\Preference'); $pref = FactoryMuffin::create('FireflyIII\Models\Preference');
@@ -79,6 +85,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::delete
*/
public function testDelete() public function testDelete()
{ {
@@ -89,6 +98,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
// fake an account. // fake an account.
@@ -106,6 +118,9 @@ class AccountControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::edit
*/
public function testEdit() public function testEdit()
{ {
// fake an account. // fake an account.
@@ -139,6 +154,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::index
*/
public function testIndex() public function testIndex()
{ {
// an account: // an account:
@@ -166,6 +184,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::show
*/
public function testShow() public function testShow()
{ {
// an account: // an account:
@@ -181,6 +202,9 @@ class AccountControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::store
*/
public function testStore() public function testStore()
{ {
// an account: // an account:
@@ -211,6 +235,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::store
*/
public function testStoreAndRedirect() public function testStoreAndRedirect()
{ {
// an account: // an account:
@@ -242,6 +269,9 @@ class AccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::update
*/
public function testUpdate() public function testUpdate()
{ {
@@ -272,6 +302,9 @@ class AccountControllerTest extends TestCase
$this->assertSessionHas('success'); $this->assertSessionHas('success');
} }
/**
* @covers FireflyIII\Http\Controllers\AccountController::update
*/
public function testUpdateAndRedirect() public function testUpdateAndRedirect()
{ {

View File

@@ -36,6 +36,9 @@ class AuthControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::postRegister
*/
public function testPostRegister() public function testPostRegister()
{ {
@@ -50,6 +53,9 @@ class AuthControllerTest extends TestCase
$this->assertSessionHas('success'); $this->assertSessionHas('success');
} }
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::postRegister
*/
public function testPostRegisterFails() public function testPostRegisterFails()
{ {

View File

@@ -38,6 +38,9 @@ class BillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::create
*/
public function testCreate() public function testCreate()
{ {
// go! // go!
@@ -56,6 +59,9 @@ class BillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::delete
*/
public function testDelete() public function testDelete()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -65,6 +71,9 @@ class BillControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -79,6 +88,9 @@ class BillControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::edit
*/
public function testEdit() public function testEdit()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -95,6 +107,9 @@ class BillControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::index
*/
public function testIndex() public function testIndex()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -116,6 +131,9 @@ class BillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::rescan
*/
public function testRescan() public function testRescan()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -135,6 +153,9 @@ class BillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::rescan
*/
public function testRescanInactive() public function testRescanInactive()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -148,6 +169,9 @@ class BillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::show
*/
public function testShow() public function testShow()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -170,6 +194,9 @@ class BillControllerTest extends TestCase
$this->call('GET', '/bills/show/' . $bill->id); $this->call('GET', '/bills/show/' . $bill->id);
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::store
*/
public function testStore() public function testStore()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -185,6 +212,9 @@ class BillControllerTest extends TestCase
$this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.'); $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.');
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::store
*/
public function testStoreAndRedirect() public function testStoreAndRedirect()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -200,6 +230,9 @@ class BillControllerTest extends TestCase
$this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.'); $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.');
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::update
*/
public function testUpdate() public function testUpdate()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -215,6 +248,9 @@ class BillControllerTest extends TestCase
$this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" updated.'); $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" updated.');
} }
/**
* @covers FireflyIII\Http\Controllers\BillController::update
*/
public function testUpdateAndRedirect() public function testUpdateAndRedirect()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');

View File

@@ -39,6 +39,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::amount
*/
public function testAmount() public function testAmount()
{ {
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
@@ -54,6 +57,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::create
*/
public function testCreate() public function testCreate()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -63,6 +69,9 @@ class BudgetControllerTest extends TestCase
$this->assertViewHas('subTitle', 'Create a new budget'); $this->assertViewHas('subTitle', 'Create a new budget');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::delete
*/
public function testDelete() public function testDelete()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -75,6 +84,9 @@ class BudgetControllerTest extends TestCase
$this->assertSessionHas('budgets.delete.url'); $this->assertSessionHas('budgets.delete.url');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -89,6 +101,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::edit
*/
public function testEdit() public function testEdit()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -102,6 +117,9 @@ class BudgetControllerTest extends TestCase
$this->assertSessionHas('budgets.edit.url'); $this->assertSessionHas('budgets.edit.url');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::index
*/
public function testIndex() public function testIndex()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -127,6 +145,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::noBudget
*/
public function testNoBudget() public function testNoBudget()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -140,6 +161,9 @@ class BudgetControllerTest extends TestCase
$this->assertViewHas('subTitle'); $this->assertViewHas('subTitle');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome
*/
public function testPostUpdateIncome() public function testPostUpdateIncome()
{ {
@@ -160,6 +184,9 @@ class BudgetControllerTest extends TestCase
$this->assertRedirectedToRoute('budgets.index'); $this->assertRedirectedToRoute('budgets.index');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::show
*/
public function testShow() public function testShow()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -179,6 +206,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::show
*/
public function testShowInvalidRepetition() public function testShowInvalidRepetition()
{ {
@@ -203,6 +233,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::store
*/
public function testStore() public function testStore()
{ {
// a budget: // a budget:
@@ -228,6 +261,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::store
*/
public function testStoreAndRedirect() public function testStoreAndRedirect()
{ {
// a budget: // a budget:
@@ -254,6 +290,9 @@ class BudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::update
*/
public function testUpdate() public function testUpdate()
{ {
@@ -280,6 +319,9 @@ class BudgetControllerTest extends TestCase
$this->assertSessionHas('success'); $this->assertSessionHas('success');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::update
*/
public function testUpdateAndRedirect() public function testUpdateAndRedirect()
{ {
@@ -307,6 +349,9 @@ class BudgetControllerTest extends TestCase
$this->assertSessionHas('success'); $this->assertSessionHas('success');
} }
/**
* @covers FireflyIII\Http\Controllers\BudgetController::updateIncome
*/
public function testUpdateIncome() public function testUpdateIncome()
{ {

View File

@@ -40,6 +40,9 @@ class CategoryControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::create
*/
public function testCreate() public function testCreate()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
@@ -50,6 +53,9 @@ class CategoryControllerTest extends TestCase
$this->assertViewHas('subTitle', 'Create a new category'); $this->assertViewHas('subTitle', 'Create a new category');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::delete
*/
public function testDelete() public function testDelete()
{ {
@@ -61,6 +67,9 @@ class CategoryControllerTest extends TestCase
$this->assertViewHas('subTitle', 'Delete category "' . e($category->name) . '"'); $this->assertViewHas('subTitle', 'Delete category "' . e($category->name) . '"');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
@@ -74,6 +83,9 @@ class CategoryControllerTest extends TestCase
$this->assertSessionHas('success', 'The category "' . e($category->name) . '" was deleted.'); $this->assertSessionHas('success', 'The category "' . e($category->name) . '" was deleted.');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::edit
*/
public function testEdit() public function testEdit()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
@@ -84,6 +96,9 @@ class CategoryControllerTest extends TestCase
$this->assertViewHas('subTitle', 'Edit category "' . e($category->name) . '"'); $this->assertViewHas('subTitle', 'Edit category "' . e($category->name) . '"');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::index
*/
public function testIndex() public function testIndex()
{ {
$collection = new Collection; $collection = new Collection;
@@ -102,6 +117,9 @@ class CategoryControllerTest extends TestCase
$this->assertViewHas('categories'); $this->assertViewHas('categories');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::noCategory
*/
public function testNoCategory() public function testNoCategory()
{ {
$collection = new Collection; $collection = new Collection;
@@ -123,6 +141,9 @@ class CategoryControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::show
*/
public function testShow() public function testShow()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
@@ -145,6 +166,10 @@ class CategoryControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::store
*/
public function testStore() public function testStore()
{ {
// create // create
@@ -164,7 +189,9 @@ class CategoryControllerTest extends TestCase
$this->assertSessionHas('success', 'New category "' . $category->name . '" stored!'); $this->assertSessionHas('success', 'New category "' . $category->name . '" stored!');
} }
// /**
* @covers FireflyIII\Http\Controllers\CategoryController::store
*/
public function testStoreAndRedirect() public function testStoreAndRedirect()
{ {
// create // create
@@ -185,6 +212,9 @@ class CategoryControllerTest extends TestCase
$this->assertSessionHas('success', 'New category "' . $category->name . '" stored!'); $this->assertSessionHas('success', 'New category "' . $category->name . '" stored!');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::update
*/
public function testUpdate() public function testUpdate()
{ {
// create // create
@@ -204,6 +234,9 @@ class CategoryControllerTest extends TestCase
$this->assertSessionHas('success', 'Category "' . $category->name . '" updated.'); $this->assertSessionHas('success', 'Category "' . $category->name . '" updated.');
} }
/**
* @covers FireflyIII\Http\Controllers\CategoryController::update
*/
public function testUpdateAndRedirect() public function testUpdateAndRedirect()
{ {
// create // create

View File

@@ -37,6 +37,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::create
*/
public function testCreate() public function testCreate()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -49,6 +52,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
*/
public function testDefaultCurrency() public function testDefaultCurrency()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -60,6 +66,9 @@ class CurrencyControllerTest extends TestCase
$this->assertSessionHas('success', $currency->name . ' is now the default currency.'); $this->assertSessionHas('success', $currency->name . ' is now the default currency.');
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::delete
*/
public function testDelete() public function testDelete()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -75,6 +84,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::delete
*/
public function testDeleteUnable() public function testDeleteUnable()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -90,6 +102,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -105,6 +120,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::destroy
*/
public function testDestroyUnable() public function testDestroyUnable()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -120,6 +138,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::edit
*/
public function testEdit() public function testEdit()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -134,6 +155,9 @@ class CurrencyControllerTest extends TestCase
$this->assertViewHas('currency'); $this->assertViewHas('currency');
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::index
*/
public function testIndex() public function testIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -148,6 +172,9 @@ class CurrencyControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::store
*/
public function testStore() public function testStore()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -166,6 +193,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::store
*/
public function testStoreAndReturn() public function testStoreAndReturn()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -184,6 +214,9 @@ class CurrencyControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::update
*/
public function testUpdate() public function testUpdate()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -200,6 +233,9 @@ class CurrencyControllerTest extends TestCase
$this->assertSessionHas('success'); $this->assertSessionHas('success');
} }
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::update
*/
public function testUpdateAndReturn() public function testUpdateAndReturn()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -38,6 +38,7 @@ class HelpControllerTest extends TestCase
/** /**
* Everything present and accounted for, and in cache: * Everything present and accounted for, and in cache:
* @covers FireflyIII\Http\Controllers\HelpController::show
*/ */
public function testGetHelpText() public function testGetHelpText()
{ {
@@ -58,6 +59,7 @@ class HelpControllerTest extends TestCase
/** /**
* Everything present and accounted for, but not cached * Everything present and accounted for, but not cached
* @covers FireflyIII\Http\Controllers\HelpController::show
*/ */
public function testGetHelpTextNoCache() public function testGetHelpTextNoCache()
{ {
@@ -80,6 +82,7 @@ class HelpControllerTest extends TestCase
/** /**
* No such route. * No such route.
* @covers FireflyIII\Http\Controllers\HelpController::show
*/ */
public function testGetHelpTextNoRoute() public function testGetHelpTextNoRoute()
{ {

View File

@@ -66,7 +66,7 @@ class HomeControllerTest extends TestCase
} }
/** /**
* * @covers FireflyIII\Http\Controllers\HomeController::flush
*/ */
public function testFlush() public function testFlush()
{ {

View File

@@ -37,6 +37,9 @@ class JsonControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid
*/
public function testBoxBillsPaid() public function testBoxBillsPaid()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -66,6 +69,9 @@ class JsonControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid
*/
public function testBoxBillsUnpaid() public function testBoxBillsUnpaid()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
@@ -92,6 +98,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxIn
*/
public function testBoxIn() public function testBoxIn()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -106,6 +115,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxOut
*/
public function testBoxOut() public function testBoxOut()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -120,6 +132,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::categories
*/
public function testCategories() public function testCategories()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
@@ -133,6 +148,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::expenseAccounts
*/
public function testExpenseAccounts() public function testExpenseAccounts()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -146,6 +164,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::revenueAccounts
*/
public function testRevenueAccounts() public function testRevenueAccounts()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -159,6 +180,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::tags
*/
public function testTags() public function testTags()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -177,6 +201,9 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\JsonController::transactionJournals
*/
public function testTransactionJournals() public function testTransactionJournals()
{ {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');

View File

@@ -42,6 +42,9 @@ class PiggyBankControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::add
*/
public function testAdd() public function testAdd()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -60,6 +63,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::create
*/
public function testCreate() public function testCreate()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -84,6 +90,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::delete
*/
public function testDelete() public function testDelete()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -95,6 +104,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertViewHas('subTitle', 'Delete "' . e($piggyBank->name) . '"'); $this->assertViewHas('subTitle', 'Delete "' . e($piggyBank->name) . '"');
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -110,6 +122,9 @@ class PiggyBankControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::edit
*/
public function testEdit() public function testEdit()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -137,6 +152,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::edit
*/
public function testEditNullDate() public function testEditNullDate()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -164,6 +182,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::index
*/
public function testIndex() public function testIndex()
{ {
$piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -194,6 +215,9 @@ class PiggyBankControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::order
*/
public function testOrder() public function testOrder()
{ {
$piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -214,6 +238,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd
*/
public function testPostAdd() public function testPostAdd()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -232,6 +259,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd
*/
public function testPostAddOverdraw() public function testPostAddOverdraw()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -250,6 +280,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::postRemove
*/
public function testPostRemove() public function testPostRemove()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -286,7 +319,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::remove
*/
public function testRemove() public function testRemove()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -300,6 +335,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::show
*/
public function testShow() public function testShow()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -316,6 +354,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::store
*/
public function testStore() public function testStore()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -338,6 +379,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::store
*/
public function testStoreCreateAnother() public function testStoreCreateAnother()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -361,6 +405,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::update
*/
public function testUpdate() public function testUpdate()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -383,6 +430,9 @@ class PiggyBankControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::update
*/
public function testUpdateReturnToEdit() public function testUpdateReturnToEdit()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');

View File

@@ -37,6 +37,9 @@ class PreferencesControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\PreferencesController::index
*/
public function testIndex() public function testIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -69,6 +72,9 @@ class PreferencesControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\PreferencesController::postIndex
*/
public function testPostIndex() public function testPostIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -34,6 +34,9 @@ class ProfileControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::changePassword
*/
public function testChangePassword() public function testChangePassword()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -43,6 +46,9 @@ class ProfileControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::deleteAccount
*/
public function testDeleteAccount() public function testDeleteAccount()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -52,6 +58,9 @@ class ProfileControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::index
*/
public function testIndex() public function testIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -61,6 +70,10 @@ class ProfileControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword
* @covers FireflyIII\Http\Controllers\ProfileController::validatePassword
*/
public function testPostChangePassword() public function testPostChangePassword()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -83,6 +96,10 @@ class ProfileControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword
* @covers FireflyIII\Http\Controllers\ProfileController::validatePassword
*/
public function testPostChangePasswordInvalidCurrent() public function testPostChangePasswordInvalidCurrent()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -105,6 +122,10 @@ class ProfileControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword
* @covers FireflyIII\Http\Controllers\ProfileController::validatePassword
*/
public function testPostChangePasswordNoNewPassword() public function testPostChangePasswordNoNewPassword()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -128,6 +149,9 @@ class ProfileControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
*/
public function testPostDeleteAccount() public function testPostDeleteAccount()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -147,6 +171,9 @@ class ProfileControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
*/
public function testPostDeleteAccountInvalidPassword() public function testPostDeleteAccountInvalidPassword()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -36,6 +36,9 @@ class ReminderControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\ReminderController::act
*/
public function testAct() public function testAct()
{ {
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder'); $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
@@ -47,6 +50,9 @@ class ReminderControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ReminderController::dismiss
*/
public function testDismiss() public function testDismiss()
{ {
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder'); $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
@@ -57,6 +63,9 @@ class ReminderControllerTest extends TestCase
$this->assertRedirectedTo('/'); $this->assertRedirectedTo('/');
} }
/**
* @covers FireflyIII\Http\Controllers\ReminderController::index
*/
public function testIndex() public function testIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -75,6 +84,9 @@ class ReminderControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ReminderController::show
*/
public function testShow() public function testShow()
{ {
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder'); $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
@@ -86,6 +98,9 @@ class ReminderControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ReminderController::show
*/
public function testShowDismissed() public function testShowDismissed()
{ {
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder'); $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');

View File

@@ -37,6 +37,9 @@ class ReportControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\ReportController::index
*/
public function testIndex() public function testIndex()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -66,6 +69,9 @@ class ReportControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\ReportController::month
*/
public function testMonth() public function testMonth()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -93,6 +99,9 @@ class ReportControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ReportController::month
*/
public function testMonthShared() public function testMonthShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -119,6 +128,9 @@ class ReportControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\ReportController::year
*/
public function testYear() public function testYear()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -36,6 +36,9 @@ class SearchControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\SearchController::index
*/
public function testSearch() public function testSearch()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -37,6 +37,9 @@ class TagControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::create
*/
public function testCreate() public function testCreate()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -46,6 +49,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::delete
*/
public function testDelete() public function testDelete()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -55,6 +61,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -66,6 +75,9 @@ class TagControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::edit
*/
public function testEdit() public function testEdit()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -75,6 +87,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::edit
*/
public function testEditBalancingAct() public function testEditBalancingAct()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -93,6 +108,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::edit
*/
public function testEditThreeExpenses() public function testEditThreeExpenses()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -116,6 +134,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::hideTagHelp
*/
public function testHideTagHelp() public function testHideTagHelp()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -125,6 +146,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::index
*/
public function testIndex() public function testIndex()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -134,6 +158,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::edit
*/
public function testMultipleDeposits() public function testMultipleDeposits()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -156,6 +183,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::show
*/
public function testShow() public function testShow()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@@ -165,6 +195,9 @@ class TagControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::store
*/
public function testStore() public function testStore()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -179,6 +212,9 @@ class TagControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::store
*/
public function testStoreWithLocation() public function testStoreWithLocation()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -214,6 +250,9 @@ class TagControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
} }
/**
* @covers FireflyIII\Http\Controllers\TagController::update
*/
public function testUpdateWithLocation() public function testUpdateWithLocation()
{ {
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');

View File

@@ -39,7 +39,9 @@ class TransactionControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::create
*/
public function testCreate() public function testCreate()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -57,6 +59,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::delete
*/
public function testDelete() public function testDelete()
{ {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@@ -66,6 +71,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::destroy
*/
public function testDestroy() public function testDestroy()
{ {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@@ -84,6 +92,7 @@ class TransactionControllerTest extends TestCase
} }
/** /**
* @covers FireflyIII\Http\Controllers\TransactionController::edit
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public function testEdit() public function testEdit()
@@ -136,6 +145,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::index
*/
public function testIndexRevenue() public function testIndexRevenue()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -152,6 +164,9 @@ class TransactionControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::index
*/
public function testIndexTransfer() public function testIndexTransfer()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -167,6 +182,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::index
*/
public function testIndexWithdrawal() public function testIndexWithdrawal()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -182,6 +200,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::reorder
*/
public function testReorder() public function testReorder()
{ {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@@ -203,6 +224,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\TransactionController::show
*/
public function testShow() public function testShow()
{ {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@@ -231,8 +255,9 @@ class TransactionControllerTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Http\Controllers\TransactionController::store
*/ */
public function testStore() public function testStoreCreateAnother()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
@@ -254,7 +279,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0', 'budget_id' => '0',
'create_another' => '1', 'create_another' => '1',
'category' => '', 'category' => '',
'tags' => '', 'tags' => 'fat-test',
'piggy_bank_id' => '0', 'piggy_bank_id' => '0',
'_token' => 'replaceMe', '_token' => 'replaceMe',
]; ];
@@ -277,6 +302,53 @@ class TransactionControllerTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Http\Controllers\TransactionController::store
*/
public function testStore()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$this->be($account->user);
$data = [
'reminder_id' => '',
'what' => 'withdrawal',
'description' => 'Bla bla bla',
'account_id' => $account->id,
'expense_account' => 'Bla bla',
'amount' => '100',
'amount_currency_id' => $currency->id,
'date' => '2015-05-05',
'budget_id' => '0',
'category' => '',
'tags' => 'fat-test',
'piggy_bank_id' => '0',
'_token' => 'replaceMe',
];
// mock!
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
// fake!
$repository->shouldReceive('store')->andReturn($journal);
$repository->shouldReceive('deactivateReminder')->andReturnNull();
$this->call('POST', '/transactions/store/withdrawal', $data);
//$this->assertSessionHas('errors','bla');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Http\Controllers\TransactionController::store
*/ */
public function testStoreTransfer() public function testStoreTransfer()
{ {
@@ -314,7 +386,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0', 'budget_id' => '0',
'create_another' => '1', 'create_another' => '1',
'category' => '', 'category' => '',
'tags' => '', 'tags' => 'fat-test',
'piggy_bank_id' => $piggy->id, 'piggy_bank_id' => $piggy->id,
'_token' => 'replaceMe', '_token' => 'replaceMe',
]; ];
@@ -337,6 +409,7 @@ class TransactionControllerTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Http\Controllers\TransactionController::update
*/ */
public function testUpdate() public function testUpdate()
{ {
@@ -362,7 +435,7 @@ class TransactionControllerTest extends TestCase
'date' => '2015-05-31', 'date' => '2015-05-31',
'budget_id' => '0', 'budget_id' => '0',
'category' => 'Lunch', 'category' => 'Lunch',
'tags' => '', 'tags' => 'fat-test',
'piggy_bank_id' => '0', 'piggy_bank_id' => '0',
]; ];
@@ -385,6 +458,7 @@ class TransactionControllerTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Http\Controllers\TransactionController::update
*/ */
public function testUpdateWithRedirect() public function testUpdateWithRedirect()
{ {
@@ -411,7 +485,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0', 'budget_id' => '0',
'category' => 'Lunch', 'category' => 'Lunch',
'return_to_edit' => 1, 'return_to_edit' => 1,
'tags' => '', 'tags' => 'fat-test',
'piggy_bank_id' => '0', 'piggy_bank_id' => '0',
]; ];

View File

@@ -28,6 +28,9 @@ class ChartAccountControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::all
*/
public function testAll() public function testAll()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -64,6 +67,9 @@ class ChartAccountControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::all
*/
public function testAllShared() public function testAllShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -93,6 +99,9 @@ class ChartAccountControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage
*/
public function testFrontpage() public function testFrontpage()
{ {
$accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]); $accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]);
@@ -110,6 +119,9 @@ class ChartAccountControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::single
*/
public function testSingle() public function testSingle()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');

View File

@@ -30,6 +30,9 @@ class ChartBillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage
*/
public function testFrontpage() public function testFrontpage()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -55,7 +58,7 @@ class ChartBillControllerTest extends TestCase
$accounts->shouldReceive('getCreditCards')->andReturn($creditCards); $accounts->shouldReceive('getCreditCards')->andReturn($creditCards);
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
$repository->shouldReceive('createFakeBill')->andReturn($bills->first()); $repository->shouldReceive('createFakeBill')->andReturn($bills->first());
Steam::shouldReceive('balance')->andReturn(-10,0); Steam::shouldReceive('balance')->andReturn(-10, 0);
$this->call('GET', '/chart/bill/frontpage'); $this->call('GET', '/chart/bill/frontpage');
@@ -63,6 +66,9 @@ class ChartBillControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BillController::single
*/
public function testSingle() public function testSingle()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');

View File

@@ -27,6 +27,9 @@ class ChartBudgetControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget
*/
public function testBudget() public function testBudget()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
@@ -38,6 +41,9 @@ class ChartBudgetControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
*/
public function testBudgetLimit() public function testBudgetLimit()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -68,6 +74,9 @@ class ChartBudgetControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
*/
public function testFrontpage() public function testFrontpage()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -116,6 +125,9 @@ class ChartBudgetControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::year
*/
public function testYear() public function testYear()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -136,6 +148,9 @@ class ChartBudgetControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::year
*/
public function testYearShared() public function testYearShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -26,18 +26,24 @@ class ChartCategoryControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::all
*/
public function testAll() public function testAll()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
$this->be($category->user); $this->be($category->user);
$this->call('GET', '/chart/category/'.$category->id.'/all'); $this->call('GET', '/chart/category/' . $category->id . '/all');
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::frontpage
*/
public function testFrontpage() public function testFrontpage()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -62,15 +68,21 @@ class ChartCategoryControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::month
*/
public function testMonth() public function testMonth()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
$this->be($category->user); $this->be($category->user);
$this->call('GET', '/chart/category/'.$category->id.'/month'); $this->call('GET', '/chart/category/' . $category->id . '/month');
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::year
*/
public function testYear() public function testYear()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -89,6 +101,9 @@ class ChartCategoryControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::year
*/
public function testYearShared() public function testYearShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -25,6 +25,9 @@ class ChartPiggyBankControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::history
*/
public function testHistory() public function testHistory()
{ {
$piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');

View File

@@ -25,6 +25,9 @@ class ChartReportControllerTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOut
*/
public function testYearInOut() public function testYearInOut()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -35,6 +38,9 @@ class ChartReportControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOut
*/
public function testYearInOutShared() public function testYearInOutShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -45,6 +51,9 @@ class ChartReportControllerTest extends TestCase
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized
*/
public function testYearInOutSummarized() public function testYearInOutSummarized()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -54,6 +63,9 @@ class ChartReportControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized
*/
public function testYearInOutSummarizedShared() public function testYearInOutSummarizedShared()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');

View File

@@ -192,7 +192,7 @@ FactoryMuffin::define(
return RandomString::generateRandomString(3); return RandomString::generateRandomString(3);
}, },
'symbol' => function () { 'symbol' => function () {
return RandomString::generateRandomString(1); return RandomString::generateRandomString(2);
}, },
'name' => 'word' 'name' => 'word'
] ]

View File

@@ -32,6 +32,7 @@ class ConnectJournalToPiggyBankTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle
*/ */
public function testNoRepetition() public function testNoRepetition()
{ {
@@ -86,6 +87,9 @@ class ConnectJournalToPiggyBankTest extends TestCase
$this->assertFalse($result); $this->assertFalse($result);
} }
/**
* @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle
*/
public function testNoSuchPiggy() public function testNoSuchPiggy()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
@@ -102,6 +106,7 @@ class ConnectJournalToPiggyBankTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle
*/ */
public function testWithRepetition() public function testWithRepetition()
{ {
@@ -162,6 +167,7 @@ class ConnectJournalToPiggyBankTest extends TestCase
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle
*/ */
public function testWithRepetitionReversed() public function testWithRepetitionReversed()
{ {

View File

@@ -38,6 +38,9 @@ class ReminderHelperTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::createReminder
*/
public function testCreateReminder() public function testCreateReminder()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -52,6 +55,9 @@ class ReminderHelperTest extends TestCase
$this->assertEquals($piggyBank->targetamount, $result->metadata->leftToSave); $this->assertEquals($piggyBank->targetamount, $result->metadata->leftToSave);
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::createReminder
*/
public function testCreateReminderHaveAlready() public function testCreateReminderHaveAlready()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -72,6 +78,9 @@ class ReminderHelperTest extends TestCase
$this->assertEquals($reminder->id, $result->id); $this->assertEquals($reminder->id, $result->id);
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::createReminder
*/
public function testCreateReminderNoTarget() public function testCreateReminderNoTarget()
{ {
$account = FactoryMuffin::create('FireflyIII\Models\Account'); $account = FactoryMuffin::create('FireflyIII\Models\Account');
@@ -88,7 +97,7 @@ class ReminderHelperTest extends TestCase
} }
/** /**
* * @covers FireflyIII\Helpers\Reminders\ReminderHelper::createReminders
*/ */
public function testCreateReminders() public function testCreateReminders()
{ {
@@ -108,6 +117,9 @@ class ReminderHelperTest extends TestCase
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderRanges
*/
public function testGetReminderRangesNull() public function testGetReminderRangesNull()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -115,6 +127,9 @@ class ReminderHelperTest extends TestCase
$this->assertEquals([], $result); $this->assertEquals([], $result);
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderRanges
*/
public function testGetReminderRangesWithTargetDate() public function testGetReminderRangesWithTargetDate()
{ {
/** @var \FireflyIII\Models\PiggyBank $piggyBank */ /** @var \FireflyIII\Models\PiggyBank $piggyBank */
@@ -131,6 +146,9 @@ class ReminderHelperTest extends TestCase
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderRanges
*/
public function testGetReminderRangesWithoutTargetDate() public function testGetReminderRangesWithoutTargetDate()
{ {
/** @var \FireflyIII\Models\PiggyBank $piggyBank */ /** @var \FireflyIII\Models\PiggyBank $piggyBank */
@@ -146,6 +164,9 @@ class ReminderHelperTest extends TestCase
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderText
*/
public function testGetReminderTextDate() public function testGetReminderTextDate()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
@@ -161,6 +182,9 @@ class ReminderHelperTest extends TestCase
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderText
*/
public function testGetReminderTextNoPiggy() public function testGetReminderTextNoPiggy()
{ {
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder'); $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
@@ -169,6 +193,9 @@ class ReminderHelperTest extends TestCase
} }
/**
* @covers FireflyIII\Helpers\Reminders\ReminderHelper::getReminderText
*/
public function testGetReminderTextNullDate() public function testGetReminderTextNullDate()
{ {
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');

View File

@@ -42,7 +42,6 @@ class ReportHelperTest extends TestCase
/** /**
* @covers FireflyIII\Helpers\Report\ReportHelper::getAccountReport * @covers FireflyIII\Helpers\Report\ReportHelper::getAccountReport
* @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts
*/ */
public function testGetAccountReport() public function testGetAccountReport()
{ {
@@ -68,8 +67,6 @@ class ReportHelperTest extends TestCase
/** /**
* @covers FireflyIII\Helpers\Report\ReportHelper::getBalanceReport * @covers FireflyIII\Helpers\Report\ReportHelper::getBalanceReport
* @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts
* @covers FireflyIII\Helpers\Report\ReportQuery::spentInBudgetCorrected
*/ */
public function testGetBalanceReport() public function testGetBalanceReport()
{ {
@@ -217,7 +214,6 @@ class ReportHelperTest extends TestCase
/** /**
* @covers FireflyIII\Helpers\Report\ReportHelper::getExpenseReport * @covers FireflyIII\Helpers\Report\ReportHelper::getExpenseReport
* @covers FireflyIII\Helpers\Report\ReportQuery::expenseInPeriodCorrected
*/ */
public function testGetExpenseReport() public function testGetExpenseReport()
{ {
@@ -278,7 +274,6 @@ class ReportHelperTest extends TestCase
/** /**
* @covers FireflyIII\Helpers\Report\ReportHelper::getIncomeReport * @covers FireflyIII\Helpers\Report\ReportHelper::getIncomeReport
* @covers FireflyIII\Helpers\Report\ReportQuery::incomeInPeriodCorrected
*/ */
public function testGetIncomeReport() public function testGetIncomeReport()
{ {

View File

@@ -1,13 +1,12 @@
<?php <?php
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportQuery; use FireflyIII\Helpers\Report\ReportQuery;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use League\FactoryMuffin\Facade as FactoryMuffin; use League\FactoryMuffin\Facade as FactoryMuffin;
/** /**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class ReportQueryTest * Class ReportQueryTest
*/ */
class ReportQueryTest extends TestCase class ReportQueryTest extends TestCase
@@ -37,64 +36,366 @@ class ReportQueryTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
public function testBalancedTransactionsList()
/**
* @covers FireflyIII\Helpers\Report\ReportQuery::expenseInPeriodCorrected
* @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions
*/
public function testExpenseInPeriodCorrected()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$date = new Carbon('2015-01-12');
for ($i = 0; $i < 10; $i++) {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $date;
$journal->user_id = $user->id;
$journal->transaction_type_id = $type->id;
$journal->save();
// two transactions:
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$account1->account_type_id = $asset->id;
$account1->user_id = $user->id;
$account2->account_type_id = $expense->id;
$account2->user_id = $user->id;
$account1->save();
$account2->save();
AccountMeta::create(
[
'account_id' => $account1->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
Transaction::create(
[
'account_id' => $account2->id,
'transaction_journal_id' => $journal->id,
'amount' => 100
]
);
Transaction::create(
[
'account_id' => $account1->id,
'transaction_journal_id' => $journal->id,
'amount' => -100
]
);
}
$this->be($user);
$set = $this->object->expenseInPeriodCorrected($start, $end, false);
$this->assertCount(10, $set);
} }
public function testBalancedTransactionsSum() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::expenseInPeriodCorrected
* @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions
*/
public function testExpenseInPeriodCorrectedShared()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$date = new Carbon('2015-01-12');
for ($i = 0; $i < 10; $i++) {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $date;
$journal->user_id = $user->id;
$journal->transaction_type_id = $type->id;
$journal->save();
// two transactions:
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$account1->account_type_id = $asset->id;
$account1->user_id = $user->id;
$account2->account_type_id = $expense->id;
$account2->user_id = $user->id;
$account1->save();
$account2->save();
AccountMeta::create(
[
'account_id' => $account1->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
Transaction::create(
[
'account_id' => $account2->id,
'transaction_journal_id' => $journal->id,
'amount' => 100
]
);
Transaction::create(
[
'account_id' => $account1->id,
'transaction_journal_id' => $journal->id,
'amount' => -100
]
);
}
$this->be($user);
$set = $this->object->expenseInPeriodCorrected($start, $end, true);
$this->assertCount(10, $set);
} }
/**
* @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts
*/
public function testGetAllAccounts() public function testGetAllAccounts()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
for ($i = 0; $i < 10; $i++) {
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$account->account_type_id = $asset->id;
$account->user_id = $user->id;
$account->save();
}
Steam::shouldReceive('balance')->andReturn(0);
$this->be($user);
$set = $this->object->getAllAccounts($start, $end, false);
$this->assertCount(10, $set);
} }
public function testGetBudgetSummary() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts
*/
public function testGetAllAccountsShared()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
for ($i = 0; $i < 10; $i++) {
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$account->account_type_id = $asset->id;
$account->user_id = $user->id;
$account->save();
}
Steam::shouldReceive('balance')->andReturn(0);
$this->be($user);
$set = $this->object->getAllAccounts($start, $end, true);
$this->assertCount(10, $set);
} }
public function testGetTransactionsWithoutBudget() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::incomeInPeriodCorrected
* @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions
*/
public function testIncomeInPeriodCorrected()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$date = new Carbon('2015-01-12');
for ($i = 0; $i < 10; $i++) {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $date;
$journal->user_id = $user->id;
$journal->transaction_type_id = $type->id;
$journal->save();
// two transactions:
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$account1->account_type_id = $asset->id;
$account1->user_id = $user->id;
$account2->account_type_id = $expense->id;
$account2->user_id = $user->id;
$account1->save();
$account2->save();
AccountMeta::create(
[
'account_id' => $account1->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
Transaction::create(
[
'account_id' => $account2->id,
'transaction_journal_id' => $journal->id,
'amount' => -100
]
);
Transaction::create(
[
'account_id' => $account1->id,
'transaction_journal_id' => $journal->id,
'amount' => 100
]
);
}
$this->be($user);
$set = $this->object->incomeInPeriodCorrected($start, $end, false);
$this->assertCount(10, $set);
} }
public function testIncomeInPeriod() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::incomeInPeriodCorrected
* @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions
*/
public function testIncomeInPeriodCorrectedShared()
{ {
$this->markTestIncomplete(); $start = new Carbon('2015-01-01');
$end = new Carbon('2015-02-01');
$user = FactoryMuffin::create('FireflyIII\User');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$date = new Carbon('2015-01-12');
for ($i = 0; $i < 10; $i++) {
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $date;
$journal->user_id = $user->id;
$journal->transaction_type_id = $type->id;
$journal->save();
// two transactions:
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$account1->account_type_id = $asset->id;
$account1->user_id = $user->id;
$account2->account_type_id = $expense->id;
$account2->user_id = $user->id;
$account1->save();
$account2->save();
AccountMeta::create(
[
'account_id' => $account1->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
Transaction::create(
[
'account_id' => $account2->id,
'transaction_journal_id' => $journal->id,
'amount' => -100
]
);
Transaction::create(
[
'account_id' => $account1->id,
'transaction_journal_id' => $journal->id,
'amount' => 100
]
);
}
$this->be($user);
$set = $this->object->incomeInPeriodCorrected($start, $end, true);
$this->assertCount(10, $set);
} }
public function testJournalsByBudget() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::spentInBudgetCorrected
*/
public function testSpentInBudgetCorrected()
{ {
$this->markTestIncomplete(); $user = FactoryMuffin::create('FireflyIII\User');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$account->user_id = $user->id;
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget->user_id = $user->id;
$account->save();
$budget->save();
$this->be($user);
$result = $this->object->spentInBudgetCorrected($account, $budget, new Carbon, new Carbon);
$this->assertEquals(0, $result);
} }
public function testJournalsByCategory() /**
* @covers FireflyIII\Helpers\Report\ReportQuery::spentNoBudget
*/
public function testSpentNoBudget()
{ {
$this->markTestIncomplete();
}
public function testJournalsByExpenseAccount() $user = FactoryMuffin::create('FireflyIII\User');
{ $account = FactoryMuffin::create('FireflyIII\Models\Account');
$this->markTestIncomplete(); $account->user_id = $user->id;
}
public function testJournalsByRevenueAccount() $account->save();
{
$this->markTestIncomplete();
}
public function testSharedExpenses() $this->be($user);
{
$this->markTestIncomplete();
}
public function testSharedExpensesByCategory() $result = $this->object->spentNoBudget($account, new Carbon, new Carbon);
{ $this->assertEquals(0, $result);
$this->markTestIncomplete();
} }
} }

View File

@@ -0,0 +1,140 @@
<?php
use FireflyIII\Models\Account;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class AccountModelTest
*/
class AccountModelTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* @covers FireflyIII\Models\Account::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncrypted()
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
// search for account with the same properties:
$search = [
'name' => $account->name,
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id
];
$result = Account::firstOrCreateEncrypted($search);
// should be the same account:
$this->assertEquals($account->id, $result->id);
}
/**
* @covers FireflyIII\Models\Account::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncryptedNew()
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$user = FactoryMuffin::create('FireflyIII\User');
// search for account with the same properties:
$search = [
'name' => 'Some new account',
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id,
'active' => 1,
];
$result = Account::firstOrCreateEncrypted($search);
// should not be the same account:
$this->assertNotEquals($account->id, $result->id);
}
/**
* @covers FireflyIII\Models\Account::firstOrNullEncrypted
*/
public function testFirstOrNullEncrypted()
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
// search for account with the same properties:
$search = [
'name' => $account->name,
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id
];
$result = Account::firstOrNullEncrypted($search);
// should be the same account:
$this->assertEquals($account->id, $result->id);
}
/**
* @covers FireflyIII\Models\Account::firstOrNullEncrypted
*/
public function testFirstOrNullEncryptedNew()
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$user = FactoryMuffin::create('FireflyIII\User');
// search for account with the same properties:
$search = [
'name' => 'Some new account',
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id,
'active' => 1,
];
$result = Account::firstOrNullEncrypted($search);
// should not be the same account:
$this->assertNull($result);
}
}

View File

@@ -0,0 +1,76 @@
<?php
use FireflyIII\Models\Category;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class CategoryModelTest
*/
class CategoryModelTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncrypted()
{
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$search = [
'name' => $category->name,
'user_id' => $category->user_id
];
$result = Category::firstOrCreateEncrypted($search);
$this->assertEquals($result->id, $category->id);
}
/**
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncryptedNew()
{
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$search = [
'name' => 'Some category name',
'user_id' => $category->user_id
];
$result = Category::firstOrCreateEncrypted($search);
$this->assertNotEquals($result->id, $category->id);
}
}

View File

@@ -0,0 +1,77 @@
<?php
use FireflyIII\Models\Tag;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class TagModelTest
*/
class TagModelTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncryptedNew()
{
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
'tag' => 'Something else',
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
$this->assertNotEquals($tag->id, $result->id);
}
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncrypted()
{
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
'tag' => $tag->tag,
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
$this->assertEquals($tag->id, $result->id);
}
}

View File

@@ -0,0 +1,388 @@
<?php
use FireflyIII\Models\Transaction;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class TransactionJournalModelTest
*/
class TransactionJournalModelTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* @covers FireflyIII\Models\TransactionJournal::getActualAmountAttribute
*/
public function testGetActualAmountAttribute()
{
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(
[
'account_id' => $account->id,
'transaction_journal_id' => $journal->id,
'amount' => 123.45
]
);
$amount = $journal->actual_amount;
$this->assertEquals('123.45', $amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetAmountAttributeAdvancePayment()
{
// make types:
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
// make tag
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->tagMode = 'advancePayment';
$tag->save();
// make withdrawal
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
// make deposit
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
// for withdrawal, asset to expense account and reversed: //89,88
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -89.88]);
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => 89.88]);
// connect to tag:
$tag->transactionJournals()->save($withdrawal);
$tag->transactionJournals()->save($deposit);
// amount should be 210.12:
$this->assertEquals('210.12', $withdrawal->amount);
$this->assertEquals('0', $deposit->amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetAmountAttributeBalancingAct()
{
// make types:
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transferType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
// make a tag
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->tagMode = 'balancingAct';
$tag->save();
// make a withdrawal and a transfer
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$transfer->transaction_type_id = $transferType->id;
$transfer->save();
// connect to tag:
$tag->transactionJournals()->save($withdrawal);
$tag->transactionJournals()->save($transfer);
// make accounts:
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
$asset2 = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
$asset2->account_type_id = $asset->account_type_id;
$asset2->save();
// make transactions:
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -123.45]);
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 123.45]);
Transaction::create(['account_id' => $asset2->id, 'transaction_journal_id' => $transfer->id, 'amount' => -123.45]);
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $transfer->id, 'amount' => 123.45]);
$amount = $withdrawal->amount;
$this->assertEquals('0', $amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
*/
public function testGetAmountAttributeNoTags()
{
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(
[
'account_id' => $account->id,
'transaction_journal_id' => $journal->id,
'amount' => 123.45
]
);
$amount = $journal->amount;
$this->assertEquals('123.45', $amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
*/
public function testGetAmountAttributeTag()
{
// has a normal tag, but nothing special.
// make tag
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->tagMode = 'nothing';
$tag->save();
// make withdrawal
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);
// connect to tag:
$tag->transactionJournals()->save($withdrawal);
$this->assertEquals('300', $withdrawal->amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAssetAccountAttribute
*/
public function testGetAssetAccountAttributeDeposit()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
// make withdrawal
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => 300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
// get asset account:
$result = $deposit->asset_account;
$this->assertEquals($asset->id, $result->id);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAssetAccountAttribute
*/
public function testGetAssetAccountAttributeFallback()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
// make withdrawal
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
// get asset account:
$result = $deposit->asset_account;
$this->assertEquals($asset->id, $result->id);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAssetAccountAttribute
*/
public function testGetAssetAccountAttributeWithdrawal()
{
// make withdrawal
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);
// get asset account:
$result = $withdrawal->asset_account;
$this->assertEquals($asset->id, $result->id);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getCorrectedActualAmountAttribute
*/
public function testGetCorrectedActualAmountAttributeDeposit()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => 300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
// get asset account:
$result = $deposit->corrected_actual_amount;
$this->assertEquals('300', $result);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getCorrectedActualAmountAttribute
*/
public function testGetCorrectedActualAmountAttributeWithdrawal()
{
// make withdrawal
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);
// get asset account:
$result = $withdrawal->corrected_actual_amount;
$this->assertEquals('-300', $result);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getDestinationAccountAttribute
*/
public function testGetDestinationAccountAttribute()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => 300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
// get asset account:
$result = $deposit->destination_account;
$this->assertEquals($asset->id, $result->id);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getDestinationAccountAttribute
*/
public function testGetDestinationAccountAttributeFallback()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$deposit->transaction_type_id = $depositType->id;
$deposit->save();
// make accounts
FactoryMuffin::create('FireflyIII\Models\Account');
$revenue = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
Transaction::create(['account_id' => $revenue->id, 'transaction_journal_id' => $deposit->id, 'amount' => -300]);
// get asset account:
$result = $deposit->destination_account;
$this->assertEquals($asset->id, $result->id);
}
}

View File

@@ -611,6 +611,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount
* @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance
*
*/ */
public function testStore() public function testStore()
{ {

View File

@@ -36,6 +36,22 @@ class BillRepositoryTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
public function testBillPaymentsInRange()
{
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth();
// payment:
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $start;
$journal->bill_id = $bill->id;
$journal->save();
$this->object->billPaymentsInRange($bill, $start, $end);
}
/** /**
* @covers FireflyIII\Repositories\Bill\BillRepository::createFakeBill * @covers FireflyIII\Repositories\Bill\BillRepository::createFakeBill
*/ */
@@ -58,8 +74,8 @@ class BillRepositoryTest extends TestCase
*/ */
public function testDestroy() public function testDestroy()
{ {
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$accountId = $bill->id; $accountId = $bill->id;
$this->object->destroy($bill); $this->object->destroy($bill);
// cannot find bill: // cannot find bill:
@@ -284,6 +300,7 @@ class BillRepositoryTest extends TestCase
/** /**
* One * One
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @covers FireflyIII\Repositories\Bill\BillRepository::scan * @covers FireflyIII\Repositories\Bill\BillRepository::scan
*/ */
public function testScanMatch() public function testScanMatch()

View File

@@ -295,7 +295,18 @@ class BudgetRepositoryTest extends TestCase
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
$amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon); $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, false);
$this->assertEquals(0, $amount);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::spentInPeriodCorrected
*/
public function testSpentInPeriodCorrectedShared()
{
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
$amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, true);
$this->assertEquals(0, $amount); $this->assertEquals(0, $amount);
} }

View File

@@ -99,9 +99,33 @@ class CategoryRepositoryTest extends TestCase
$category->save(); $category->save();
} }
for ($i = 0; $i < 5; $i++) {
$journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
/** @var Category $category */
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$journal1->user_id = $user->id;
$journal1->date = new Carbon('2015-02-11');
$journal1->transaction_type_id = $type->id;
$journal2->user_id = $user->id;
$journal2->date = new Carbon('2015-02-11');
$journal2->transaction_type_id = $type->id;
$category->user_id = $user->id;
$category->transactionjournals()->save($journal1);
$category->transactionjournals()->save($journal2);
$journal1->save();
$journal2->save();
$category->save();
}
$this->be($user); $this->be($user);
$set = $this->object->getCategoriesAndExpensesCorrected(new Carbon('2015-02-01'), new Carbon('2015-02-28')); $set = $this->object->getCategoriesAndExpensesCorrected(new Carbon('2015-02-01'), new Carbon('2015-02-28'));
$this->assertCount(5, $set); $this->assertCount(10, $set);
reset($set); reset($set);
$this->assertEquals(0, current($set)['sum']); $this->assertEquals(0, current($set)['sum']);
@@ -196,7 +220,20 @@ class CategoryRepositoryTest extends TestCase
public function testSpentInPeriodSumCorrected() public function testSpentInPeriodSumCorrected()
{ {
$category = FactoryMuffin::create('FireflyIII\Models\Category'); $category = FactoryMuffin::create('FireflyIII\Models\Category');
$sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon); $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, false);
$this->assertEquals(0, $sum);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::spentInPeriodCorrected
*/
public function testSpentInPeriodSumCorrectedShared()
{
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, true);
$this->assertEquals(0, $sum); $this->assertEquals(0, $sum);

View File

@@ -92,6 +92,8 @@ class JournalRepositoryTest extends TestCase
*/ */
public function testGetAmountBefore() public function testGetAmountBefore()
{ {
$transaction = FactoryMuffin::create('FireflyIII\Models\Transaction'); $transaction = FactoryMuffin::create('FireflyIII\Models\Transaction');
$before = $this->object->getAmountBefore($transaction->transactionjournal, $transaction); $before = $this->object->getAmountBefore($transaction->transactionjournal, $transaction);
@@ -167,6 +169,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
*/ */
public function testStore() public function testStore()
{ {
@@ -199,6 +203,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
*/ */
public function testStoreDeposit() public function testStoreDeposit()
{ {
@@ -236,6 +242,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
*/ */
public function testStoreExpenseWithCash() public function testStoreExpenseWithCash()
{ {
@@ -272,6 +280,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException * @expectedException Symfony\Component\HttpKernel\Exception\HttpException
*/ */
public function testStoreInvalidFromAccount() public function testStoreInvalidFromAccount()
@@ -311,6 +321,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException * @expectedException Symfony\Component\HttpKernel\Exception\HttpException
*/ */
public function testStoreInvalidToAccount() public function testStoreInvalidToAccount()
@@ -350,6 +362,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
*/ */
public function testStoreRevenueWithCash() public function testStoreRevenueWithCash()
{ {
@@ -387,6 +401,8 @@ class JournalRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store * @covers FireflyIII\Repositories\Journal\JournalRepository::store
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts
*/ */
public function testStoreTransfer() public function testStoreTransfer()
{ {

View File

@@ -145,6 +145,29 @@ class PiggyBankRepositoryTest extends TestCase
$this->assertEquals(1, $piggyBank->id); $this->assertEquals(1, $piggyBank->id);
} }
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::store
*/
public function testStoreRedirect()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$data = [
'remind_me' => 1,
'account_id' => $account->id,
'name' => 'Some piggy',
'targetamount' => 100,
'create_another' => 1,
'reminder_skip' => 0,
'order' => 1,
];
$piggyBank = $this->object->store($data);
$this->assertEquals(1, $piggyBank->id);
}
/** /**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::update * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::update
*/ */