Some tests and a rename.

This commit is contained in:
James Cole
2014-12-30 17:55:46 +01:00
parent 1f0e692ee2
commit 9f92e1b7bd
15 changed files with 150 additions and 45 deletions

View File

@@ -44,7 +44,7 @@ class ReportController extends BaseController
try {
new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) {
View::make('error')->with('message', 'Invalid date');
return View::make('error')->with('message', 'Invalid date');
}
$date = new Carbon($year . '-' . $month . '-01');
$dayEarly = clone $date;
@@ -81,7 +81,7 @@ class ReportController extends BaseController
try {
new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) {
View::make('error')->with('message', 'Invalid date');
return View::make('error')->with('message', 'Invalid date.');
}
$date = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y');
@@ -110,7 +110,7 @@ class ReportController extends BaseController
try {
new Carbon('01-01-' . $year);
} catch (Exception $e) {
App::abort(500);
return View::make('error')->with('message', 'Invalid date.');
}
$date = new Carbon('01-01-' . $year);
$end = clone $date;

View File

@@ -174,46 +174,6 @@ class PiggyBankShared
}
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
exit;
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggy_bank_periods'))) {
$errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');
}
// check period.
if (!$errors->has('reminder') && !$errors->has('targetdate') && isset($model['remind_me']) && intval($model['remind_me']) == 1) {
$today = new Carbon;
$target = new Carbon($model['targetdate']);
switch ($model['reminder']) {
case 'week':
$today->addWeek();
break;
case 'month':
$today->addMonth();
break;
case 'year':
$today->addYear();
break;
}
if ($today > $target) {
$errors->add('reminder', 'Target date is too close to today to set reminders.');
}
}
$validator = \Validator::make($model, \PiggyBank::$rules);
if ($validator->invalid()) {
$errors->merge($errors);
}
// add ok messages.
$list = ['name', 'account_id', 'targetamount', 'targetdate', 'remind_me', 'reminder'];
foreach ($list as $entry) {
if (!$errors->has($entry) && !$warnings->has($entry)) {
$successes->add($entry, 'OK');
}
}
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
}

View File

@@ -388,7 +388,7 @@ class Report implements ReportInterface
->where('acm_to.data', '!=', '"sharedExpense"')
->before($end)->after($start)
->where('transaction_journals.user_id', \Auth::user()->id)
->groupBy('account_id')->orderBy('sum')->limit(15)
->groupBy('t_from.account_id')->orderBy('sum')->limit(15)
->get(['t_from.account_id as account_id', 'ac_from.name as name', \DB::Raw('SUM(t_from.amount) as `sum`')]);

View File

@@ -231,7 +231,7 @@ class ReportQuery implements ReportQueryInterface
->where('account_meta.data', '!=', '"sharedExpense"')
->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id')
->orderBy('name', 'ASC')
->orderBy('budgets.name', 'ASC')
->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
}

View File

@@ -2,6 +2,9 @@
/**
* Class BillControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class BillControllerCest
{
@@ -147,6 +150,9 @@ class BillControllerCest
$I->see('Could not store bill');
}
/**
* @param FunctionalTester $I
*/
public function storeRecreate(FunctionalTester $I)
{
$I->wantTo('validate a bill and create another one');

View File

@@ -2,6 +2,10 @@
/**
* Class PreferencesControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
*/
class PreferencesControllerCest
{

View File

@@ -2,6 +2,9 @@
/**
* Class ProfileControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class ProfileControllerCest
{

View File

@@ -2,6 +2,9 @@
/**
* Class ReminderControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class ReminderControllerCest
{
@@ -21,6 +24,9 @@ class ReminderControllerCest
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function act(FunctionalTester $I)
{
$I->wantTo('act on a reminder');
@@ -28,6 +34,9 @@ class ReminderControllerCest
$I->see('Money for Weekly reminder for clothes');
}
/**
* @param FunctionalTester $I
*/
public function dismiss(FunctionalTester $I)
{
$I->wantTo('dismiss a reminder');
@@ -35,6 +44,9 @@ class ReminderControllerCest
$I->see('Reminder dismissed');
}
/**
* @param FunctionalTester $I
*/
public function notNow(FunctionalTester $I)
{
$I->wantTo('ignore a reminder');
@@ -42,6 +54,9 @@ class ReminderControllerCest
$I->see('Reminder dismissed');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('see a reminder');
@@ -50,6 +65,9 @@ class ReminderControllerCest
$I->see('your piggy bank labelled "Weekly reminder for clothes"');
}
/**
* @param FunctionalTester $I
*/
public function actOnInvalid(FunctionalTester $I)
{
$I->wantTo('act on an invalid reminder');

View File

@@ -2,7 +2,12 @@
/**
* Class RepeatedExpenseControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class RepeatedExpenseControllerCest
{
/**
@@ -20,6 +25,9 @@ class RepeatedExpenseControllerCest
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a recurring transaction');
@@ -27,6 +35,9 @@ class RepeatedExpenseControllerCest
$I->see('Create new repeated expense');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a recurring transaction');
@@ -34,6 +45,9 @@ class RepeatedExpenseControllerCest
$I->see('Delete "Nieuwe kleding"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy a recurring transaction');
@@ -42,6 +56,9 @@ class RepeatedExpenseControllerCest
$I->dontSeeInDatabase('piggy_banks', ['id' => 5]);
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a recurring transaction');
@@ -50,6 +67,9 @@ class RepeatedExpenseControllerCest
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('see all recurring transactions');
@@ -58,6 +78,9 @@ class RepeatedExpenseControllerCest
$I->see('Nieuwe kleding');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('view a recurring transaction');
@@ -65,6 +88,9 @@ class RepeatedExpenseControllerCest
$I->see('Nieuwe kleding');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->wantTo('store a recurring transaction');
@@ -86,6 +112,9 @@ class RepeatedExpenseControllerCest
$I->see('Piggy bank "TestRepeatedExpense" stored.');
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update a recurring transaction');
@@ -107,6 +136,9 @@ class RepeatedExpenseControllerCest
$I->see('Repeated expense "Nieuwe kleding!" updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturnToEdit(FunctionalTester $I)
{
$I->wantTo('update a recurring transaction and return to edit screen');
@@ -128,6 +160,9 @@ class RepeatedExpenseControllerCest
$I->see('Repeated expense "Nieuwe kleding!" updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateFail(FunctionalTester $I)
{
$I->wantTo('try to update a recurring transaction and fail');

View File

@@ -0,0 +1,79 @@
<?php
/**
* Class ReportControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
*/
class ReportControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function budget(FunctionalTester $I)
{
$I->wantTo('see a budget report');
$I->amOnPage('/reports/budget/2014/9');
$I->see('Budget report for September 2014');
}
public function budgetInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a budget report for an invalid date');
$I->amOnPage('/reports/budget/XXXX/XX');
$I->see('Invalid date');
}
public function index(FunctionalTester $I)
{
$I->wantTo('see all possible reports');
$I->amOnPage('/reports');
$I->see('Reports');
$I->see('Monthly reports');
$I->see('Budget reports');
}
public function month(FunctionalTester $I)
{
$I->wantTo('see a monthly report');
$I->amOnPage('/reports/2014/9');
$I->see('Report for September 2014');
}
public function monthInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a monthly report for an invalid month');
$I->amOnPage('/reports/XXXX/XX');
$I->see('Invalid date');
}
public function year(FunctionalTester $I)
{
$I->wantTo('see a yearly report');
$I->amOnPage('/reports/2014');
$I->see('Income vs. expenses');
$I->see('Account balance');
}
public function yearInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a yearly report for an invalid year');
$I->amOnPage('/reports/XXXX');
$I->see('Invalid date');
}
}