From 124c9303b97b2886f6259f07f7b5e7f1aceb104a Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 23 Jun 2015 22:13:13 +0200 Subject: [PATCH] This should fix the tests. --- app/Http/Controllers/PiggyBankController.php | 26 +++++++++++-------- app/Models/PiggyBank.php | 4 +-- .../PiggyBank/PiggyBankRepository.php | 5 +++- tests/factories/all.php | 2 ++ .../repositories/PiggyBankRepositoryTest.php | 4 +++ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 7f420b917d..fecc0978c3 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -297,7 +297,7 @@ class PiggyBankController extends Controller */ public function show(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) { - $events = $repository->getEvents($piggyBank); + $events = $repository->getEvents($piggyBank); $subTitle = e($piggyBank->name); return view('piggy-banks.show', compact('piggyBank', 'events', 'subTitle')); @@ -314,11 +314,13 @@ class PiggyBankController extends Controller { $piggyBankData = [ - 'name' => $request->get('name'), - 'startdate' => new Carbon, - 'account_id' => intval($request->get('account_id')), - 'targetamount' => floatval($request->get('targetamount')), - 'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null, + 'name' => $request->get('name'), + 'startdate' => new Carbon, + 'account_id' => intval($request->get('account_id')), + 'targetamount' => floatval($request->get('targetamount')), + 'remind_me' => false, + 'reminder_skip' => 0, + 'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null, ]; $piggyBank = $repository->store($piggyBankData); @@ -347,11 +349,13 @@ class PiggyBankController extends Controller public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank) { $piggyBankData = [ - 'name' => $request->get('name'), - 'startdate' => is_null($piggyBank->startdate) ? $piggyBank->created_at : $piggyBank->startdate, - 'account_id' => intval($request->get('account_id')), - 'targetamount' => floatval($request->get('targetamount')), - 'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null, + 'name' => $request->get('name'), + 'startdate' => is_null($piggyBank->startdate) ? $piggyBank->created_at : $piggyBank->startdate, + 'account_id' => intval($request->get('account_id')), + 'targetamount' => floatval($request->get('targetamount')), + 'remind_me' => false, + 'reminder_skip' => 0, + 'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null, ]; $piggyBank = $repository->update($piggyBank, $piggyBankData); diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index f7f0c7053e..ebe5379da2 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class PiggyBank * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at @@ -43,7 +43,7 @@ class PiggyBank extends Model use SoftDeletes; protected $fillable - = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate']; + = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'remind_me', 'reminder_skip']; protected $hidden = ['targetamount_encrypted', 'encrypted']; /** diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 4b4787825e..231b09b60d 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -116,7 +116,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface */ public function store(array $data) { - $piggyBank = PiggyBank::create($data); + $data['remind_me'] = false; + $data['reminder_skip'] = 0; + + $piggyBank = PiggyBank::create($data); return $piggyBank; } diff --git a/tests/factories/all.php b/tests/factories/all.php index aa9075e351..96a6bb4044 100644 --- a/tests/factories/all.php +++ b/tests/factories/all.php @@ -237,6 +237,8 @@ FactoryMuffin::define( }, 'startdate' => 'date', 'targetdate' => 'date', + 'remind_me' => false, + 'reminder_skip' => 0, 'order' => 0, ] ); diff --git a/tests/repositories/PiggyBankRepositoryTest.php b/tests/repositories/PiggyBankRepositoryTest.php index 590e410a5a..79c9079c4e 100644 --- a/tests/repositories/PiggyBankRepositoryTest.php +++ b/tests/repositories/PiggyBankRepositoryTest.php @@ -138,6 +138,8 @@ class PiggyBankRepositoryTest extends TestCase 'name' => 'Some piggy', 'targetamount' => 100, 'order' => 1, + 'remind_me' => false, + 'reminder_skip' => 0, ]; @@ -161,6 +163,8 @@ class PiggyBankRepositoryTest extends TestCase 'targetamount' => 100, 'create_another' => 1, 'order' => 1, + 'remind_me' => false, + 'reminder_skip' => 0, ];