From a0b12ece541757e85eb59fd81cf4744a88627de1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 21 Aug 2014 15:16:12 +0200 Subject: [PATCH] Fixes for tests. --- app/models/Limit.php | 18 +---- app/models/LimitRepetition.php | 18 ----- app/models/PiggybankRepetition.php | 17 ----- app/models/TransactionJournal.php | 16 ----- app/models/TransactionType.php | 4 -- .../controllers/ProfileControllerTest.php | 3 + app/tests/factories/Category.php | 2 +- app/tests/factories/Limit.php | 24 +++++++ app/tests/factories/LimitRepetition.php | 26 +++++++ app/tests/factories/Piggybank.php | 30 ++++++++ app/tests/factories/PiggybankRepetition.php | 23 ++++++ app/tests/factories/RecurringTransaction.php | 23 ++++++ app/tests/factories/TransactionCurrency.php | 12 ++++ app/tests/factories/TransactionJournal.php | 17 +++++ app/tests/factories/TransactionType.php | 15 ++++ app/views/recurring/show.blade.php | 71 +++++++++++++++++++ 16 files changed, 246 insertions(+), 73 deletions(-) create mode 100644 app/tests/factories/Limit.php create mode 100644 app/tests/factories/LimitRepetition.php create mode 100644 app/tests/factories/Piggybank.php create mode 100644 app/tests/factories/PiggybankRepetition.php create mode 100644 app/tests/factories/RecurringTransaction.php create mode 100644 app/tests/factories/TransactionCurrency.php create mode 100644 app/tests/factories/TransactionJournal.php create mode 100644 app/tests/factories/TransactionType.php create mode 100644 app/views/recurring/show.blade.php diff --git a/app/models/Limit.php b/app/models/Limit.php index 856a736acb..275d34249d 100644 --- a/app/models/Limit.php +++ b/app/models/Limit.php @@ -35,27 +35,11 @@ class Limit extends Ardent 'component_id' => 'required|exists:components,id', 'startdate' => 'required|date', 'amount' => 'numeric|required|min:0.01', - 'repeats' => 'required|between:0,1', + 'repeats' => 'required|boolean', 'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly' ]; - /** - * @return array - */ - public static function factory() - { - $start = new Carbon; - $start->startOfMonth(); - - return [ - 'component_id' => 'factory|Budget', - 'startdate' => $start, - 'amount' => '100', - 'repeats' => 0, - 'repeat_freq' => 'monthly' - ]; - } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php index d8b44d4c61..3ce5871432 100644 --- a/app/models/LimitRepetition.php +++ b/app/models/LimitRepetition.php @@ -31,24 +31,6 @@ class LimitRepetition extends Ardent 'amount' => 'numeric|required|min:0.01', ]; - /** - * @return array - */ - public static function factory() - { - $start = new \Carbon\Carbon; - $start->startOfMonth(); - $end = clone $start; - $end->endOfMonth(); - - return [ - 'limit_id' => 'factory|Limit', - 'startdate' => $start, - 'enddate' => $end, - 'amount' => 100 - ]; - } - /** * @return array */ diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php index ab23994d79..065734661a 100644 --- a/app/models/PiggybankRepetition.php +++ b/app/models/PiggybankRepetition.php @@ -32,23 +32,6 @@ class PiggybankRepetition extends Ardent 'currentamount' => 'required|numeric' ]; - /** - * @return array - */ - public static function factory() - { - $start = new Carbon; - $start->startOfMonth(); - $end = new Carbon; - $end->endOfMonth(); - - return [ - 'piggybank_id' => 'factory|Piggybank', - 'startdate' => $start->format('Y-m-d'), - 'targetdate' => $end->format('Y-m-d'), - 'currentamount' => 200 - ]; - } public function pct() { $total = $this->piggybank->targetamount; diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index a862a69664..a7c4f74c2d 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -52,22 +52,6 @@ class TransactionJournal extends Ardent 'completed' => 'required|between:0,1' ]; - /** - * @return array - */ - public static function factory() - { - $date = new \Carbon\Carbon; - - return [ - 'transaction_type_id' => 'factory|TransactionType', - 'transaction_currency_id' => 'factory|TransactionCurrency', - 'description' => 'string', - 'completed' => '1', - 'user_id' => 'factory|User', - 'date' => $date - ]; - } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany diff --git a/app/models/TransactionType.php b/app/models/TransactionType.php index 652589c782..0fea66cadd 100644 --- a/app/models/TransactionType.php +++ b/app/models/TransactionType.php @@ -17,10 +17,6 @@ use LaravelBook\Ardent\Ardent; */ class TransactionType extends Ardent { - public static $factory - = [ - 'type' => 'string' - ]; /** * @return \Illuminate\Database\Eloquent\Relations\HasMany diff --git a/app/tests/controllers/ProfileControllerTest.php b/app/tests/controllers/ProfileControllerTest.php index fb82c75faf..b293c4300a 100644 --- a/app/tests/controllers/ProfileControllerTest.php +++ b/app/tests/controllers/ProfileControllerTest.php @@ -71,6 +71,8 @@ class ProfileControllerTest extends TestCase public function testPostChangePasswordOK() { $user = f::create('User'); + $user->password = 'sander'; + $user->save(); // for binding Auth::shouldReceive('user')->andReturn($user); Auth::shouldReceive('check')->andReturn(true); @@ -82,6 +84,7 @@ class ProfileControllerTest extends TestCase 'POST', 'ProfileController@postChangePassword', ['old' => 'sander', 'new1' => 'sander2', 'new2' => 'sander2'] ); + $this->assertSessionHas('success'); $this->assertResponseStatus(302); } diff --git a/app/tests/factories/Category.php b/app/tests/factories/Category.php index 71f1df47e8..559f27a85e 100644 --- a/app/tests/factories/Category.php +++ b/app/tests/factories/Category.php @@ -2,7 +2,7 @@ use League\FactoryMuffin\Facade; Facade::define( - 'Budget', + 'Category', [ 'name' => 'word', 'user_id' => 'factory|User', diff --git a/app/tests/factories/Limit.php b/app/tests/factories/Limit.php new file mode 100644 index 0000000000..7c3c36780a --- /dev/null +++ b/app/tests/factories/Limit.php @@ -0,0 +1,24 @@ + 'factory|Budget', + 'startdate' => function () { + $start = new Carbon; + $start->startOfMonth(); + return $start; + }, + 'amount' => 100, + 'repeats' => 'boolean', + 'repeat_freq' => function(){ + $frequencies = ['daily','weekly','monthly','quarterly','half-year','yearly']; + return $frequencies[rand(0,5)]; + } + + + ] +); \ No newline at end of file diff --git a/app/tests/factories/LimitRepetition.php b/app/tests/factories/LimitRepetition.php new file mode 100644 index 0000000000..61370085a6 --- /dev/null +++ b/app/tests/factories/LimitRepetition.php @@ -0,0 +1,26 @@ + 'factory|Limit', + 'startdate' => function () { + $start = new Carbon; + $start->startOfMonth(); + return $start; + + }, + 'enddate' => function () { + $end = new Carbon; + $end->endOfMonth(); + return $end; + + }, + 'amount' => 100 + + + ] +); \ No newline at end of file diff --git a/app/tests/factories/Piggybank.php b/app/tests/factories/Piggybank.php new file mode 100644 index 0000000000..48b665d49b --- /dev/null +++ b/app/tests/factories/Piggybank.php @@ -0,0 +1,30 @@ + 'factory|Account', + 'name' => 'string', + 'targetamount' => 'integer', + 'startdate' => function () { + $start = new Carbon; + $start->startOfMonth(); + return $start; + }, + 'targetdate' => function () { + $end = new Carbon; + $end->endOfMonth(); + return $end; + }, + 'repeats' => 0, + 'rep_length' => null, + 'rep_times' => 0, + 'rep_every' => 0, + 'reminder' => null, + 'reminder_skip' => 0, + 'order' => 1, + ] +); \ No newline at end of file diff --git a/app/tests/factories/PiggybankRepetition.php b/app/tests/factories/PiggybankRepetition.php new file mode 100644 index 0000000000..5589ae294a --- /dev/null +++ b/app/tests/factories/PiggybankRepetition.php @@ -0,0 +1,23 @@ + 'factory|Piggybank', + 'startdate' => function () { + $start = new Carbon; + $start->startOfMonth(); + return $start; + }, + 'targetdate' => function () { + $end = new Carbon; + $end->endOfMonth(); + return $end; + }, + 'currentamount' => 200 + ] +); \ No newline at end of file diff --git a/app/tests/factories/RecurringTransaction.php b/app/tests/factories/RecurringTransaction.php new file mode 100644 index 0000000000..560f6b2f75 --- /dev/null +++ b/app/tests/factories/RecurringTransaction.php @@ -0,0 +1,23 @@ + 'factory|User', + 'name' => 'string', + 'match' => 'string', + 'amount_max' => 100, + 'amount_min' => 50, + 'date' => new Carbon, + 'active' => 'boolean', + 'automatch' => 'boolean', + 'repeat_freq' => 'monthly', + 'skip' => 'boolean', + + ] +); \ No newline at end of file diff --git a/app/tests/factories/TransactionCurrency.php b/app/tests/factories/TransactionCurrency.php new file mode 100644 index 0000000000..2e650df36d --- /dev/null +++ b/app/tests/factories/TransactionCurrency.php @@ -0,0 +1,12 @@ + 'EUR' + ] +); \ No newline at end of file diff --git a/app/tests/factories/TransactionJournal.php b/app/tests/factories/TransactionJournal.php new file mode 100644 index 0000000000..e952c8d747 --- /dev/null +++ b/app/tests/factories/TransactionJournal.php @@ -0,0 +1,17 @@ + 'factory|TransactionType', + 'transaction_currency_id' => 'factory|TransactionCurrency', + 'description' => 'word', + 'completed' => 'boolean', + 'user_id' => 'factory|User', + 'date' => new Carbon + ] +); \ No newline at end of file diff --git a/app/tests/factories/TransactionType.php b/app/tests/factories/TransactionType.php new file mode 100644 index 0000000000..32bf484f39 --- /dev/null +++ b/app/tests/factories/TransactionType.php @@ -0,0 +1,15 @@ + function() { + $types = ['Withdrawal','Deposit','Transfer','Opening balance']; + return $types[rand(0,3)]; + } + ] +); \ No newline at end of file diff --git a/app/views/recurring/show.blade.php b/app/views/recurring/show.blade.php new file mode 100644 index 0000000000..b2ea1de8c1 --- /dev/null +++ b/app/views/recurring/show.blade.php @@ -0,0 +1,71 @@ +@extends('layouts.default') +@section('content') +
+
+

Firefly + Recurring transaction "{{{$recurring->name}}}" +

+

Use recurring transactions to track repeated withdrawals

+

+

+

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Matches on: + @foreach(explode(' ',$recurring->match) as $word) + {{{$word}}} + @endforeach +
Between {{mf($recurring->amount_min)}} – {{mf($recurring->amount_max)}}
Repeats{{ucfirst($recurring->repeat_freq)}}
Next reminder{{$recurring->next()->format('d-m-Y')}}
Will be auto-matched + @if($recurring->automatch) + + @else + + @endif +
Is active + @if($recurring->active) + + @else + + @endif +
+ + + + + +
+
+@stop \ No newline at end of file