mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 01:11:37 -06:00
Some code cleanup and fixes.
This commit is contained in:
parent
c50a9b4b04
commit
fbd056104a
@ -102,12 +102,7 @@ class AccountController extends \BaseController
|
||||
|
||||
$account = $this->_repository->store(Input::all());
|
||||
|
||||
if (!$account->id) {
|
||||
// did not save, return with error:
|
||||
Session::flash('error', 'Could not save the new account. Please check the form.');
|
||||
|
||||
return Redirect::route('accounts.create')->withErrors($account->errors())->withInput();
|
||||
} else {
|
||||
if ($account->validate()) {
|
||||
// saved! return to wherever.
|
||||
Session::flash('success', 'Account "' . $account->name . '" created!');
|
||||
if (Input::get('create') == '1') {
|
||||
@ -115,6 +110,12 @@ class AccountController extends \BaseController
|
||||
} else {
|
||||
return Redirect::route('accounts.index');
|
||||
}
|
||||
} else {
|
||||
// did not save, return with error:
|
||||
Session::flash('error', 'Could not save the new account. Please check the form.');
|
||||
|
||||
return Redirect::route('accounts.create')->withErrors($account->errors())->withInput();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class BudgetController extends BaseController
|
||||
|
||||
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
|
||||
'filters', $filters
|
||||
)->with('highlight',Input::get('highlight'));
|
||||
)->with('highlight', Input::get('highlight'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ class BudgetController extends BaseController
|
||||
{
|
||||
|
||||
$budget = $this->_repository->store(Input::all());
|
||||
if ($budget->id) {
|
||||
if ($budget->validate()) {
|
||||
Event::fire('budgets.change');
|
||||
Session::flash('success', 'Budget created!');
|
||||
|
||||
|
@ -68,8 +68,8 @@ class CategoryController extends BaseController
|
||||
public function store()
|
||||
{
|
||||
$category = $this->_repository->store(Input::all());
|
||||
if ($category->id) {
|
||||
Session::flash('success', 'Category created!');
|
||||
if ($category->validate()) {
|
||||
Session::flash('success', 'Category "' . $category->name . '" created!');
|
||||
|
||||
if (Input::get('create') == '1') {
|
||||
return Redirect::route('categories.create');
|
||||
|
@ -68,7 +68,8 @@ class ChartController extends BaseController
|
||||
// loop and get array data.
|
||||
|
||||
$url = count($accounts) == 1 && is_array($accounts)
|
||||
? '<a href="' . route('accounts.show', [$account->id]) . '">View more</a>' :
|
||||
? '<a href="' . route('accounts.show', [$account->id]) . '">View more</a>'
|
||||
:
|
||||
'<a href="' . route('accounts.index') . '">View more</a>';
|
||||
$data = [
|
||||
'chart_title' => count($accounts) == 1 ? $accounts[0]->name : 'All accounts',
|
||||
|
@ -15,10 +15,10 @@ class HomeController extends BaseController
|
||||
protected $_budgets;
|
||||
|
||||
/**
|
||||
* @param ARI $accounts
|
||||
* @param PHI $preferences
|
||||
* @param TJRI $journal
|
||||
* @param BRI $budgets
|
||||
* @param ARI $accounts
|
||||
* @param PHI $preferences
|
||||
* @param TJRI $journal
|
||||
* @param BRI $budgets
|
||||
*/
|
||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, BRI $budgets)
|
||||
{
|
||||
|
@ -86,16 +86,19 @@ class LimitController extends BaseController
|
||||
|
||||
// find a limit with these properties, as we might already have one:
|
||||
$limit = $this->_limits->store(Input::all());
|
||||
if ($limit->id) {
|
||||
if ($limit->validate()) {
|
||||
Session::flash('success', 'Envelope created!');
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
return Redirect::route('budgets.index.budget');
|
||||
}
|
||||
} else {
|
||||
Session::flash('success', 'Could not save new envelope.');
|
||||
$budgetId = $budget ? $budget->id : null;
|
||||
|
||||
return Redirect::route('budgets.limits.create', [$budgetId, 'from' => Input::get('from')])->withInput();
|
||||
$parameters = [$budgetId, 'from' => Input::get('from')];
|
||||
return Redirect::route('budgets.limits.create', $parameters)->withInput()
|
||||
->withErrors($limit->errors());
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,16 +109,13 @@ class LimitController extends BaseController
|
||||
*/
|
||||
public function update(\Limit $limit)
|
||||
{
|
||||
// TODO move logic to repository.
|
||||
/** @var \Limit $limit */
|
||||
$limit->startdate = new \Carbon\Carbon(Input::get('date'));
|
||||
$limit->repeat_freq = Input::get('period');
|
||||
$limit->repeats = !is_null(Input::get('repeats')) && Input::get('repeats') == '1' ? 1 : 0;
|
||||
$limit->amount = floatval(Input::get('amount'));
|
||||
if (!$limit->save()) {
|
||||
Session::flash('error', 'Could not save new limit: ' . $limit->errors()->first());
|
||||
|
||||
return Redirect::route('budgets.limits.edit', [$limit->id, 'from' => Input::get('from')])->withInput();
|
||||
} else {
|
||||
if ($limit->save()) {
|
||||
Session::flash('success', 'Limit saved!');
|
||||
foreach ($limit->limitrepetitions()->get() as $rep) {
|
||||
$rep->delete();
|
||||
@ -125,6 +125,13 @@ class LimitController extends BaseController
|
||||
} else {
|
||||
return Redirect::route('budgets.index.budget');
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
Session::flash('error', 'Could not save new limit: ' . $limit->errors()->first());
|
||||
|
||||
return Redirect::route('budgets.limits.edit', [$limit->id, 'from' => Input::get('from')])->withInput()
|
||||
->withErrors($limit->errors());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,19 +82,20 @@ class PiggybankController extends BaseController
|
||||
public function store()
|
||||
{
|
||||
$piggyBank = $this->_repository->store(Input::all());
|
||||
if (!$piggyBank->id) {
|
||||
Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());
|
||||
|
||||
return Redirect::route('piggybanks.create')->withInput();
|
||||
} else {
|
||||
if ($piggyBank->validate()) {
|
||||
Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');
|
||||
|
||||
|
||||
if (Input::get('create') == '1') {
|
||||
return Redirect::route('piggybanks.create')->withInput();
|
||||
}
|
||||
|
||||
return Redirect::route('piggybanks.index');
|
||||
|
||||
|
||||
} else {
|
||||
Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());
|
||||
|
||||
return Redirect::route('piggybanks.create')->withInput();
|
||||
}
|
||||
|
||||
}
|
||||
@ -103,9 +104,17 @@ class PiggybankController extends BaseController
|
||||
{
|
||||
|
||||
$piggyBank = $this->_repository->update(Input::all());
|
||||
Session::flash('success', 'Piggy bank "' . $piggyBank->name . '" updated.');
|
||||
if ($piggyBank->validate()) {
|
||||
Session::flash('success', 'Piggy bank "' . $piggyBank->name . '" updated.');
|
||||
|
||||
return Redirect::route('piggybanks.index');
|
||||
} else {
|
||||
Session::flash('error', 'Could not update piggy bank: ' . $piggyBank->errors()->first());
|
||||
|
||||
return Redirect::route('piggybanks.edit', $piggyBank->id)->withErrors($piggyBank->errors())->withInput();
|
||||
}
|
||||
|
||||
|
||||
return Redirect::route('piggybanks.index');
|
||||
}
|
||||
|
||||
public function updateAmount(Piggybank $piggybank)
|
||||
|
@ -60,7 +60,7 @@ class RecurringController extends BaseController
|
||||
public function store()
|
||||
{
|
||||
$recurringTransaction = $this->_repository->store(Input::all());
|
||||
if ($recurringTransaction->id) {
|
||||
if ($recurringTransaction->validate()) {
|
||||
Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!');
|
||||
if (Input::get('create') == '1') {
|
||||
return Redirect::route('recurring.create')->withInput();
|
||||
|
@ -145,19 +145,19 @@ class TransactionController extends BaseController
|
||||
*/
|
||||
public function store($what)
|
||||
{
|
||||
$transactionJournal = $this->_repository->store($what, Input::all());
|
||||
if ($transactionJournal->id) {
|
||||
Session::flash('success', 'Transaction "' . $transactionJournal->description . '" saved!');
|
||||
$journal = $this->_repository->store($what, Input::all());
|
||||
if ($journal->validate()) {
|
||||
Session::flash('success', 'Transaction "' . $journal->description . '" saved!');
|
||||
if (Input::get('create') == '1') {
|
||||
return Redirect::route('transactions.create', [$what])->withInput();
|
||||
} else {
|
||||
return Redirect::route('transactions.index');
|
||||
}
|
||||
} else {
|
||||
Session::flash('error', 'Could not save transaction: ' . $transactionJournal->errors()->first());
|
||||
Session::flash('error', 'Could not save transaction: ' . $journal->errors()->first());
|
||||
|
||||
return Redirect::route('transactions.create', [$what])->withInput()->withErrors(
|
||||
$transactionJournal->errors()
|
||||
$journal->errors()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ class Category implements CategoryInterface
|
||||
public function journalsInRange(\Category $category, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $category->transactionjournals()->with(
|
||||
['transactions', 'transactions.account', 'transactiontype', 'components']
|
||||
)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->before($end)->after($start)->get();
|
||||
['transactions', 'transactions.account', 'transactiontype', 'components']
|
||||
)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->before($end)->after($start)->get();
|
||||
|
||||
}
|
||||
}
|
@ -96,7 +96,9 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
public function findByName($name, \AccountType $type = null)
|
||||
{
|
||||
$type = is_null($type) ? \AccountType::where('description', 'Default account')->first() : $type;
|
||||
return \Auth::user()->accounts()->where('account_type_id',$type->id)->where('name', 'like', '%' . $name . '%')->first();
|
||||
|
||||
return \Auth::user()->accounts()->where('account_type_id', $type->id)->where('name', 'like', '%' . $name . '%')
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,8 +7,10 @@ use Carbon\Carbon;
|
||||
|
||||
class EloquentRecurringTransactionRepository implements RecurringTransactionRepositoryInterface
|
||||
{
|
||||
public function destroy(\RecurringTransaction $recurringTransaction) {
|
||||
public function destroy(\RecurringTransaction $recurringTransaction)
|
||||
{
|
||||
$recurringTransaction->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -27,8 +29,9 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
||||
$recurringTransaction->amount_min = floatval($data['amount_min']);
|
||||
|
||||
// both amounts zero:
|
||||
if($recurringTransaction->amount_max == 0 && $recurringTransaction->amount_min == 0) {
|
||||
$recurringTransaction->errors()->add('amount_max','Amount max and min cannot both be zero.');
|
||||
if ($recurringTransaction->amount_max == 0 && $recurringTransaction->amount_min == 0) {
|
||||
$recurringTransaction->errors()->add('amount_max', 'Amount max and min cannot both be zero.');
|
||||
|
||||
return $recurringTransaction;
|
||||
}
|
||||
|
||||
@ -38,9 +41,10 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
||||
$recurringTransaction->skip = isset($data['skip']) ? intval($data['skip']) : 0;
|
||||
$recurringTransaction->repeat_freq = $data['repeat_freq'];
|
||||
|
||||
if($recurringTransaction->validate()) {
|
||||
if ($recurringTransaction->validate()) {
|
||||
$recurringTransaction->save();
|
||||
}
|
||||
|
||||
return $recurringTransaction;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
|
||||
// do budget:
|
||||
$budget = $budRepository->find($data['budget_id']);
|
||||
if(!is_null($budget)) {
|
||||
if (!is_null($budget)) {
|
||||
$journal->budgets()->attach($budget);
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ class EloquentUserRepository implements UserRepositoryInterface
|
||||
if (!$user->save()) {
|
||||
\Log::error('Invalid user');
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->errors()->first());
|
||||
|
||||
return false;
|
||||
}
|
||||
$user->save();
|
||||
|
@ -63,6 +63,14 @@ use LaravelBook\Ardent\Ardent;
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
*/
|
||||
class TransactionJournal extends Ardent
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ class AccountControllerTest extends TestCase
|
||||
public function testStoreFails()
|
||||
{
|
||||
$account = f::create('Account');
|
||||
unset($account->id);
|
||||
unset($account->name);
|
||||
$this->_repository->shouldReceive('store')->andReturn($account);
|
||||
$this->action('POST', 'AccountController@store');
|
||||
$this->assertRedirectedToRoute('accounts.create');
|
||||
|
@ -5,7 +5,8 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Mockery as m;
|
||||
use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
|
||||
|
||||
class BudgetControllerTest extends TestCase {
|
||||
class BudgetControllerTest extends TestCase
|
||||
{
|
||||
protected $_repository;
|
||||
protected $_user;
|
||||
protected $_budgets;
|
||||
@ -77,7 +78,7 @@ class BudgetControllerTest extends TestCase {
|
||||
Event::shouldReceive('fire')->once()->with('budgets.change');
|
||||
$this->_repository->shouldReceive('destroy')->once()->andReturn(true);
|
||||
|
||||
$this->action('POST', 'BudgetController@destroy', [$budget->id,'from' => 'date']);
|
||||
$this->action('POST', 'BudgetController@destroy', [$budget->id, 'from' => 'date']);
|
||||
$this->assertRedirectedToRoute('budgets.index');
|
||||
$this->assertSessionHas('success');
|
||||
}
|
||||
@ -140,7 +141,6 @@ class BudgetControllerTest extends TestCase {
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn($budget->email);
|
||||
|
||||
|
||||
|
||||
$this->session(['start' => new Carbon, 'end' => new Carbon]);
|
||||
|
||||
$this->_budgets->shouldReceive('organizeRepetitions')->once()->andReturn([]);
|
||||
@ -159,11 +159,10 @@ class BudgetControllerTest extends TestCase {
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn($budget->email);
|
||||
|
||||
|
||||
|
||||
$this->session(['start' => new Carbon, 'end' => new Carbon]);
|
||||
|
||||
$this->_budgets->shouldReceive('outsideRepetitions')->once()->andReturn([]);
|
||||
$this->action('GET', 'BudgetController@show', [$budget->id,'noenvelope' => 'true']);
|
||||
$this->action('GET', 'BudgetController@show', [$budget->id, 'noenvelope' => 'true']);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
@ -178,11 +177,10 @@ class BudgetControllerTest extends TestCase {
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn($budget->email);
|
||||
|
||||
|
||||
|
||||
$this->session(['start' => new Carbon, 'end' => new Carbon]);
|
||||
|
||||
// $this->_budgets->shouldReceive('show')->once()->andReturn([]);
|
||||
$arr = [0 => ['limitrepetition' => null, 'limit' => null,'date' => '']];
|
||||
$arr = [0 => ['limitrepetition' => null, 'limit' => null, 'date' => '']];
|
||||
$this->_budgets->shouldReceive('organizeRepetition')->once()->andReturn($arr);
|
||||
$this->action('GET', 'BudgetController@show', [$budget->id, 'rep' => '1']);
|
||||
$this->assertResponseOk();
|
||||
@ -195,20 +193,21 @@ class BudgetControllerTest extends TestCase {
|
||||
$this->action('POST', 'BudgetController@store');
|
||||
$this->assertRedirectedToRoute('budgets.index.budget');
|
||||
}
|
||||
|
||||
public function testStoreFromDate()
|
||||
{
|
||||
$budget = f::create('Budget');
|
||||
$this->_repository->shouldReceive('store')->andReturn($budget);
|
||||
$this->action('POST', 'BudgetController@store',['from' => 'date']);
|
||||
$this->action('POST', 'BudgetController@store', ['from' => 'date']);
|
||||
$this->assertRedirectedToRoute('budgets.index');
|
||||
}
|
||||
|
||||
public function testStoreFails()
|
||||
{
|
||||
$budget = f::create('Budget');
|
||||
unset($budget->id);
|
||||
unset($budget->name);
|
||||
$this->_repository->shouldReceive('store')->andReturn($budget);
|
||||
$this->action('POST', 'BudgetController@store',['from'=>'budget']);
|
||||
$this->action('POST', 'BudgetController@store', ['from' => 'budget']);
|
||||
$this->assertRedirectedToRoute('budgets.create');
|
||||
}
|
||||
|
||||
@ -216,8 +215,8 @@ class BudgetControllerTest extends TestCase {
|
||||
{
|
||||
$budget = f::create('Budget');
|
||||
$this->_repository->shouldReceive('store')->andReturn($budget);
|
||||
$this->action('POST', 'BudgetController@store', ['from' => 'budget','create' => '1']);
|
||||
$this->assertRedirectedToRoute('budgets.create',['from' => 'budget']);
|
||||
$this->action('POST', 'BudgetController@store', ['from' => 'budget', 'create' => '1']);
|
||||
$this->assertRedirectedToRoute('budgets.create', ['from' => 'budget']);
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
@ -243,7 +242,7 @@ class BudgetControllerTest extends TestCase {
|
||||
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
|
||||
$this->_repository->shouldReceive('update')->andReturn($budget);
|
||||
|
||||
$this->action('POST', 'BudgetController@update', [$budget->id,'from' => 'date']);
|
||||
$this->action('POST', 'BudgetController@update', [$budget->id, 'from' => 'date']);
|
||||
$this->assertRedirectedToRoute('budgets.index');
|
||||
|
||||
}
|
||||
|
@ -118,8 +118,6 @@ class CategoryControllerTest extends TestCase
|
||||
$this->session(['start' => new Carbon, 'end' => new Carbon]);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->_category->shouldReceive('journalsInRange')->once()->andReturn([]);
|
||||
$this->action('GET', 'CategoryController@show', $category->id);
|
||||
$this->assertResponseOk();
|
||||
@ -136,7 +134,7 @@ class CategoryControllerTest extends TestCase
|
||||
public function testStoreFails()
|
||||
{
|
||||
$category = f::create('Category');
|
||||
unset($category->id);
|
||||
unset($category->name);
|
||||
$this->_repository->shouldReceive('store')->andReturn($category);
|
||||
$this->action('POST', 'CategoryController@store');
|
||||
$this->assertRedirectedToRoute('categories.create');
|
||||
|
@ -86,7 +86,7 @@ class ChartControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($account->user_id);
|
||||
$this->_accounts->shouldReceive('findByName')->andReturn($account);
|
||||
|
||||
$this->_charts->shouldReceive('accountDailySummary')->once()->andReturn(['rows' => [],'sum' => 0]);
|
||||
$this->_charts->shouldReceive('accountDailySummary')->once()->andReturn(['rows' => [], 'sum' => 0]);
|
||||
|
||||
$this->call('GET', 'chart/home/info/' . $account->name . '/01/08/2014');
|
||||
$this->assertResponseOk();
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
|
||||
|
||||
/**
|
||||
* Class JsonControllerTest
|
||||
*/
|
||||
|
@ -126,6 +126,7 @@ class LimitControllerTest extends TestCase
|
||||
|
||||
$this->_limits->shouldReceive('store')->once()->andReturn($limit);
|
||||
$this->action('POST', 'LimitController@store');
|
||||
$this->assertRedirectedToRoute('budgets.index.budget');
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
@ -137,10 +138,12 @@ class LimitControllerTest extends TestCase
|
||||
$limit->save();
|
||||
$limitrepetition = f::create('LimitRepetition');
|
||||
$limit->limitrepetitions()->save($limitrepetition);
|
||||
unset($limit->id);
|
||||
unset($limit->startdate);
|
||||
unset($limit->component_id);
|
||||
|
||||
|
||||
$this->_limits->shouldReceive('store')->once()->andReturn($limit);
|
||||
$this->action('POST', 'LimitController@store', [$budget->id, 'from' => 'date']);
|
||||
$this->action('POST', 'LimitController@store', $budget->id);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class PiggybankControllerTest extends TestCase
|
||||
$two->account()->associate($aOne);
|
||||
$three = f::create('Piggybank');
|
||||
$three->account()->associate($aTwo);
|
||||
$this->_piggybanks->shouldReceive('get')->andReturn([$one,$two,$three]);
|
||||
$this->_piggybanks->shouldReceive('get')->andReturn([$one, $two, $three]);
|
||||
$this->_piggybanks->shouldReceive('count')->andReturn(1);
|
||||
$this->action('GET', 'PiggybankController@index');
|
||||
$this->assertResponseOk();
|
||||
@ -131,7 +131,7 @@ class PiggybankControllerTest extends TestCase
|
||||
public function testStoreFails()
|
||||
{
|
||||
$piggyBank = f::create('Piggybank');
|
||||
unset($piggyBank->id);
|
||||
unset($piggyBank->amount);
|
||||
$this->_piggybanks->shouldReceive('store')->andReturn($piggyBank);
|
||||
$this->action('POST', 'PiggybankController@store');
|
||||
$this->assertResponseStatus(302);
|
||||
@ -141,7 +141,7 @@ class PiggybankControllerTest extends TestCase
|
||||
{
|
||||
$piggyBank = f::create('Piggybank');
|
||||
$this->_piggybanks->shouldReceive('store')->andReturn($piggyBank);
|
||||
$this->action('POST', 'PiggybankController@store',['create' => '1']);
|
||||
$this->action('POST', 'PiggybankController@store', ['create' => '1']);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
@ -163,6 +163,25 @@ class PiggybankControllerTest extends TestCase
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testUpdateFails()
|
||||
{
|
||||
$piggyBank = f::create('Piggybank');
|
||||
unset($piggyBank->amount);
|
||||
|
||||
$this->_piggybanks->shouldReceive('update')->andReturn($piggyBank);
|
||||
|
||||
// for binding
|
||||
Auth::shouldReceive('user')->andReturn($this->_user);
|
||||
Auth::shouldReceive('check')->andReturn(true);
|
||||
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn(
|
||||
$piggyBank->account()->first()->user_id
|
||||
);
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
|
||||
$this->action('POST', 'PiggybankController@update', $piggyBank->id);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testUpdateAmount()
|
||||
{
|
||||
$piggyBank = f::create('Piggybank');
|
||||
|
@ -35,8 +35,8 @@ class PreferencesControllerTest extends TestCase
|
||||
$viewRange->shouldReceive('getAttribute')->with('data')->andReturn('1M');
|
||||
|
||||
$this->_accounts->shouldReceive('getDefault')->andReturn([]);
|
||||
$this->_helper->shouldReceive('get')->with('viewRange','1M')->andReturn($viewRange);
|
||||
$this->_helper->shouldReceive('get')->with('frontpageAccounts',[])->andReturn([]);
|
||||
$this->_helper->shouldReceive('get')->with('viewRange', '1M')->andReturn($viewRange);
|
||||
$this->_helper->shouldReceive('get')->with('frontpageAccounts', [])->andReturn([]);
|
||||
|
||||
|
||||
$this->action('GET', 'PreferencesController@index');
|
||||
@ -45,9 +45,9 @@ class PreferencesControllerTest extends TestCase
|
||||
|
||||
public function testPostIndex()
|
||||
{
|
||||
$this->_helper->shouldReceive('set')->with('frontpageAccounts',[1]);
|
||||
$this->_helper->shouldReceive('set')->with('viewRange','1M');
|
||||
$this->action('POST', 'PreferencesController@postIndex',['frontpageAccounts' => [1],'viewRange' => '1M']);
|
||||
$this->_helper->shouldReceive('set')->with('frontpageAccounts', [1]);
|
||||
$this->_helper->shouldReceive('set')->with('viewRange', '1M');
|
||||
$this->action('POST', 'PreferencesController@postIndex', ['frontpageAccounts' => [1], 'viewRange' => '1M']);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
}
|
@ -92,7 +92,7 @@ class ProfileControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
$this->_user->shouldReceive('getAttribute')->with('password')->andReturn('Blablabla');
|
||||
|
||||
$this->action('POST', 'ProfileController@postChangePassword',['old' => '']);
|
||||
$this->action('POST', 'ProfileController@postChangePassword', ['old' => '']);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn('some@email');
|
||||
|
||||
|
||||
$this->action('GET', 'RecurringController@delete',$recurringTransaction->id);
|
||||
$this->action('GET', 'RecurringController@delete', $recurringTransaction->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
$this->_repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->action('POST', 'RecurringController@destroy',$recurringTransaction->id);
|
||||
$this->action('POST', 'RecurringController@destroy', $recurringTransaction->id);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
$this->_repository->shouldReceive('destroy')->andReturn(false);
|
||||
|
||||
$this->action('POST', 'RecurringController@destroy',$recurringTransaction->id);
|
||||
$this->action('POST', 'RecurringController@destroy', $recurringTransaction->id);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($recurringTransaction->user_id);
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn('some@email');
|
||||
|
||||
$this->action('GET', 'RecurringController@edit',$recurringTransaction->id);
|
||||
$this->action('GET', 'RecurringController@edit', $recurringTransaction->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
|
||||
|
||||
$this->action('GET', 'RecurringController@show',$recurringTransaction->id);
|
||||
$this->action('GET', 'RecurringController@show', $recurringTransaction->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
@ -130,17 +130,18 @@ class RecurringControllerTest extends TestCase
|
||||
$recurringTransaction = f::create('RecurringTransaction');
|
||||
|
||||
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
||||
$this->action('POST', 'RecurringController@store',['create' => '1']);
|
||||
$this->action('POST', 'RecurringController@store', ['create' => '1']);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testStoreFails()
|
||||
{
|
||||
$recurringTransaction = f::create('RecurringTransaction');
|
||||
unset($recurringTransaction->id);
|
||||
unset($recurringTransaction->active);
|
||||
unset($recurringTransaction->automatch);
|
||||
|
||||
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
||||
$this->action('POST', 'RecurringController@store',['create' => '1']);
|
||||
$this->action('POST', 'RecurringController@store', ['create' => '1']);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
@ -155,7 +156,7 @@ class RecurringControllerTest extends TestCase
|
||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||
|
||||
|
||||
$this->action('POST', 'RecurringController@update',$recurringTransaction->id);
|
||||
$this->action('POST', 'RecurringController@update', $recurringTransaction->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
}
|
@ -242,7 +242,7 @@ class TransactionControllerTest extends TestCase
|
||||
public function testStoreFails()
|
||||
{
|
||||
$journal = f::create('TransactionJournal');
|
||||
unset($journal->id);
|
||||
unset($journal->description);
|
||||
|
||||
$this->_repository->shouldReceive('store')->andReturn($journal);
|
||||
|
||||
|
@ -311,25 +311,25 @@ class ModelTest extends TestCase
|
||||
$journal = f::create('TransactionJournal');
|
||||
|
||||
$user->accounts()->save($account);
|
||||
$this->assertEquals($account->id,$user->accounts()->first()->id);
|
||||
$this->assertEquals($account->id, $user->accounts()->first()->id);
|
||||
|
||||
$user->components()->save($comp);
|
||||
$this->assertEquals($comp->id,$user->components()->first()->id);
|
||||
$this->assertEquals($comp->id, $user->components()->first()->id);
|
||||
|
||||
$user->budgets()->save($bud);
|
||||
$this->assertEquals($bud->id,$user->budgets()->first()->id);
|
||||
$this->assertEquals($bud->id, $user->budgets()->first()->id);
|
||||
|
||||
$user->categories()->save($cat);
|
||||
$this->assertEquals($cat->id,$user->categories()->first()->id);
|
||||
$this->assertEquals($cat->id, $user->categories()->first()->id);
|
||||
|
||||
$user->preferences()->save($pref);
|
||||
$this->assertEquals($pref->id,$user->preferences()->first()->id);
|
||||
$this->assertEquals($pref->id, $user->preferences()->first()->id);
|
||||
|
||||
$user->recurringtransactions()->save($rec);
|
||||
$this->assertEquals($rec->id,$user->recurringtransactions()->first()->id);
|
||||
$this->assertEquals($rec->id, $user->recurringtransactions()->first()->id);
|
||||
|
||||
$user->transactionjournals()->save($journal);
|
||||
$this->assertEquals($journal->id,$user->transactionjournals()->first()->id);
|
||||
$this->assertEquals($journal->id, $user->transactionjournals()->first()->id);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user