New tests and prep for future runs.

This commit is contained in:
James Cole 2015-04-20 21:57:20 +02:00
parent 7d32e50f25
commit 54125c05d3
8 changed files with 515 additions and 32 deletions

View File

@ -1,12 +1,12 @@
<?php namespace FireflyIII\Http\Controllers;
use Amount;
use Auth;
use Carbon\Carbon;
use Config;
use ExpandedForm;
use FireflyIII\Http\Requests;
use FireflyIII\Http\Requests\PiggyBankFormRequest;
use FireflyIII\Models\Account;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@ -56,13 +56,13 @@ class PiggyBankController extends Controller
/**
* @return mixed
*/
public function create()
public function create(AccountRepositoryInterface $repository)
{
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = ExpandedForm::makeSelectList(
Auth::user()->accounts()->orderBy('accounts.name', 'ASC')->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*'])
);
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
//Auth::user()->accounts()->orderBy('accounts.name', 'ASC')->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*'])
// );
$subTitle = 'Create new piggy bank';
$subTitleIcon = 'fa-plus';
@ -95,11 +95,12 @@ class PiggyBankController extends Controller
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(PiggyBank $piggyBank)
public function destroy(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
{
Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.');
$piggyBank->delete();
$repository->destroy($piggyBank);
return Redirect::to(Session::get('piggy-banks.delete.url'));
}
@ -111,13 +112,11 @@ class PiggyBankController extends Controller
*
* @return $this
*/
public function edit(PiggyBank $piggyBank)
public function edit(PiggyBank $piggyBank, AccountRepositoryInterface $repository)
{
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = ExpandedForm::makeSelectList(
Auth::user()->accounts()->orderBy('accounts.name', 'ASC')->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*'])
);
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
$subTitleIcon = 'fa-pencil';
@ -151,16 +150,16 @@ class PiggyBankController extends Controller
/**
* @return $this
*/
public function index(AccountRepositoryInterface $repository)
public function index(AccountRepositoryInterface $repository, PiggyBankRepositoryInterface $piggyRepository)
{
/** @var Collection $piggyBanks */
$piggyBanks = Auth::user()->piggyBanks()->orderBy('order', 'ASC')->get();
$piggyBanks = $piggyRepository->getPiggyBanks();
$accounts = [];
/** @var PiggyBank $piggyBank */
foreach ($piggyBanks as $piggyBank) {
$piggyBank->savedSoFar = floatval($piggyBank->currentRelevantRep()->currentamount);
$piggyBank->percentage = intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100);
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
$piggyBank->leftToSave = $piggyBank->targetamount - $piggyBank->savedSoFar;
/*
@ -223,8 +222,8 @@ class PiggyBankController extends Controller
$repetition->currentamount += $amount;
$repetition->save();
// create event.
PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
// create event
$repository->createEvent($piggyBank, $amount);
/*
* Create event!
@ -244,7 +243,7 @@ class PiggyBankController extends Controller
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postRemove(PiggyBank $piggyBank)
public function postRemove(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
{
$amount = floatval(Input::get('amount'));
@ -255,12 +254,8 @@ class PiggyBankController extends Controller
$repetition->currentamount -= $amount;
$repetition->save();
PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount * -1, 'piggy_bank_id' => $piggyBank->id]);
/*
* Create event!
*/
//Event::fire('piggy_bank.removeMoney', [$piggyBank, $amount]); // new and used.
// create event
$repository->createEvent($piggyBank, $amount * -1);
Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
} else {
@ -287,10 +282,9 @@ class PiggyBankController extends Controller
*
* @return $this
*/
public function show(PiggyBank $piggyBank)
public function show(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
{
$events = $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
$events = $repository->getEvents($piggyBank);
/*
* Number of reminders:
@ -310,6 +304,7 @@ class PiggyBankController extends Controller
*/
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
{
$piggyBankData = [
'name' => $request->get('name'),
'startdate' => new Carbon,
@ -354,7 +349,6 @@ class PiggyBankController extends Controller
'remind_me' => $request->get('remind_me')
];
$piggyBank = $repository->update($piggyBank, $piggyBankData);
Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".');

View File

@ -3,8 +3,10 @@
namespace FireflyIII\Repositories\PiggyBank;
use Auth;
use Carbon\Carbon;
use DB;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\PiggyBankRepetition;
use Illuminate\Support\Collection;
use Navigation;
@ -69,6 +71,19 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return $bars;
}
/**
* @param PiggyBank $piggyBank
* @param $amount
*
* @return bool
*/
public function createEvent(PiggyBank $piggyBank, $amount)
{
PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
return true;
}
/**
* @param array $data
*
@ -87,6 +102,16 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return $part;
}
/**
* @param PiggyBank $piggyBank
*
* @return bool
*/
public function destroy(PiggyBank $piggyBank)
{
return $piggyBank->delete();
}
/**
* @param PiggyBank $piggyBank
*
@ -97,7 +122,32 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return DB::table('piggy_bank_events')->where('piggy_bank_id', $piggyBank->id)->groupBy('date')->get(['date', DB::Raw('SUM(`amount`) AS `sum`')]);
}
/**
* @param PiggyBank $piggyBank
*
* @return Collection
*/
public function getEvents(PiggyBank $piggyBank)
{
return $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
}
/**
* @return Collection
*/
public function getPiggyBanks()
{
/** @var Collection $set */
$set = Auth::user()->piggyBanks()->orderBy('order', 'ASC')->get();
$set->sortBy(
function (PiggyBank $piggyBank) {
return $piggyBank->name;
}
);
return $set;
}
/**
* Set all piggy banks to order 0.

View File

@ -27,6 +27,18 @@ interface PiggyBankRepositoryInterface
*/
public function calculateParts(PiggyBankRepetition $repetition);
/**
* @return Collection
*/
public function getPiggyBanks();
/**
* @param PiggyBank $piggyBank
*
* @return Collection
*/
public function getEvents(PiggyBank $piggyBank);
/**
* @param array $data
*
@ -34,6 +46,14 @@ interface PiggyBankRepositoryInterface
*/
public function createPiggyBankPart(array $data);
/**
* @param PiggyBank $piggyBank
* @param $amount
*
* @return bool
*/
public function createEvent(PiggyBank $piggyBank, $amount);
/**
* @param PiggyBank $piggyBank
*
@ -41,6 +61,13 @@ interface PiggyBankRepositoryInterface
*/
public function getEventSummarySet(PiggyBank $piggyBank);
/**
* @param PiggyBank $piggyBank
*
* @return bool
*/
public function destroy(PiggyBank $piggyBank);
/**
* Set all piggy banks to order 0.
*

View File

@ -24,7 +24,6 @@
<logging>
<log type="coverage-clover" target="./storage/coverage/clover.xml" charset="UTF-8" />
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>

2
pu.sh
View File

@ -18,4 +18,4 @@ then
fi
# restore .env file
mv .env.backup .env
cp .env.local .env

View File

@ -29,6 +29,10 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
public function setUp()
{
parent::setUp();
// if the database copy does not exist, call migrate.
// if the database copy does not exist, create it and copy back as original.
Artisan::call('migrate');
FactoryMuffin::loadFactories(__DIR__ . '/factories');
@ -44,10 +48,21 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
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();
// delete copy and original.
}
/**
* @param string $class
*
* @return mixed
* @return Mockery\MockInterface
*/
public function mock($class)
{

View File

@ -35,7 +35,6 @@ class JsonControllerTest extends TestCase
public function tearDown()
{
parent::tearDown();
}
public function testBoxBillsPaid()

View File

@ -0,0 +1,399 @@
<?php
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class PiggyBankControllerTest
*/
class PiggyBankControllerTest 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();
}
public function testAdd()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
// mock
/** @var Mockery\MockInterface $repository */
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('leftOnAccount')->withAnyArgs()->andReturn(12);
Amount::shouldReceive('format')->andReturn('XXxx');
$this->call('GET', '/piggy-banks/add/' . $piggyBank->id);
$this->assertResponseOk();
}
public function testCreate()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$collection = new Collection([$account]);
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// mock
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection);
ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]);
// also cover the view now that we've touched ExpandedForm:
ExpandedForm::shouldReceive('text')->andReturn('');
ExpandedForm::shouldReceive('select')->andReturn('');
ExpandedForm::shouldReceive('amount')->andReturn('');
ExpandedForm::shouldReceive('date')->andReturn('');
ExpandedForm::shouldReceive('checkbox')->andReturn('');
ExpandedForm::shouldReceive('optionsList')->andReturn('');
$this->call('GET', '/piggy-banks/create');
$this->assertResponseOk();
}
public function testDelete()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$this->call('GET', '/piggy-banks/delete/' . $piggyBank->id);
$this->assertResponseOk();
$this->assertViewHas('subTitle', 'Delete "' . e($piggyBank->name) . '"');
}
public function testDestroy()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$repository->shouldReceive('destroy')->once()->withAnyArgs()->andReturn(true);
$this->call('POST', '/piggy-banks/destroy/' . $piggyBank->id, ['_token' => 'replaceMe']);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
public function testEdit()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$collection = new Collection([$account]);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection);
ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]);
// also cover the view now that we've touched ExpandedForm:
ExpandedForm::shouldReceive('text')->andReturn('');
ExpandedForm::shouldReceive('select')->andReturn('');
ExpandedForm::shouldReceive('amount')->andReturn('');
ExpandedForm::shouldReceive('date')->andReturn('');
ExpandedForm::shouldReceive('checkbox')->andReturn('');
ExpandedForm::shouldReceive('optionsList')->andReturn('');
$this->call('GET', '/piggy-banks/edit/' . $piggyBank->id);
$this->assertResponseOk();
}
public function testEditNullDate()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$piggyBank->targetdate = null;
$piggyBank->save();
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$collection = new Collection([$account]);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection);
ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]);
// also cover the view now that we've touched ExpandedForm:
ExpandedForm::shouldReceive('text')->andReturn('');
ExpandedForm::shouldReceive('select')->andReturn('');
ExpandedForm::shouldReceive('amount')->andReturn('');
ExpandedForm::shouldReceive('date')->andReturn('');
ExpandedForm::shouldReceive('checkbox')->andReturn('');
ExpandedForm::shouldReceive('optionsList')->andReturn('');
$this->call('GET', '/piggy-banks/edit/' . $piggyBank->id);
$this->assertResponseOk();
}
public function testIndex()
{
$piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggyBank2 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggyBank3 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggyBank2->account_id = $piggyBank1->account_id;
$user = FactoryMuffin::create('FireflyIII\User');
$piggyBank2->save();
$collection = new Collection([$piggyBank1, $piggyBank2, $piggyBank3]);
$this->be($user);
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
// act!
$piggyBanks->shouldReceive('getPiggyBanks')->once()->andReturn($collection);
Steam::shouldReceive('balance')->andReturn(20);
$accounts->shouldReceive('leftOnAccount')->andReturn(12);
Amount::shouldReceive('format')->andReturn('123');
$this->call('GET', '/piggy-banks');
$this->assertResponseOk();
}
public function testOrder()
{
$piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggyBank2 = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// mock!
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('reset')->once();
$piggyBanks->shouldReceive('setOrder');
$array = [
$piggyBank1->id => 0,
$piggyBank2->id => 1,
];
$this->call('POST', '/piggy-banks/sort', ['_token' => 'replaceMe', 'order' => $array]);
$this->assertResponseOk();
}
public function testPostAdd()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']);
$this->assertResponseStatus(302);
}
public function testPostAddOverdraw()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']);
$this->assertResponseStatus(302);
}
public function testPostRemove()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencySymbol')->andReturn('something');
$this->call('POST', '/piggy-banks/remove/' . $piggyBank->id, ['_token' => 'replaceMe']);
$this->assertResponseStatus(302);
}
public function testPostRemoveOverdraw()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
// mock!
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$accounts->shouldReceive('leftOnAccount')->andReturn(20);
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencySymbol')->andReturn('something');
$this->call('POST', '/piggy-banks/remove/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']);
$this->assertResponseStatus(302);
}
public function testRemove()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
Amount::shouldReceive('format')->andReturn('something');
$this->call('GET', '/piggy-banks/remove/' . $piggyBank->id);
$this->assertResponseOk();
}
public function testShow()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('getEvents')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencySymbol')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('something');
$this->call('GET', '/piggy-banks/show/' . $piggyBank->id);
$this->assertResponseOk();
}
public function testStore()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$piggyBankData = [
'name' => 'Some name' . rand(1, 100),
'account_id' => $piggyBank->account_id,
'targetamount' => 100,
'targetdate' => '',
'reminder' => 'month',
'_token' => 'replaceMe'
];
// mock!
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('store')->once()->andReturn($piggyBank);
$this->call('POST', '/piggy-banks/store', $piggyBankData);
$this->assertResponseStatus(302);
}
public function testStoreCreateAnother()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$piggyBankData = [
'name' => 'Some name' . rand(1, 100),
'account_id' => $piggyBank->account_id,
'targetamount' => 100,
'targetdate' => '',
'reminder' => 'month',
'create_another' => 1,
'_token' => 'replaceMe'
];
// mock!
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('store')->once()->andReturn($piggyBank);
$this->call('POST', '/piggy-banks/store', $piggyBankData);
$this->assertResponseStatus(302);
}
public function testUpdate()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$piggyBankData = [
'name' => 'Some name' . rand(1, 100),
'account_id' => $piggyBank->account_id,
'targetamount' => 200,
'targetdate' => '',
'reminder' => 'month',
'_token' => 'replaceMe'
];
// mock!
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('update')->once()->andReturn($piggyBank);
$this->call('POST', '/piggy-banks/update/' . $piggyBank->id, $piggyBankData);
$this->assertResponseStatus(302);
}
public function testUpdateReturnToEdit()
{
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$this->be($piggyBank->account->user);
$piggyBankData = [
'name' => 'Some name' . rand(1, 100),
'account_id' => $piggyBank->account_id,
'targetamount' => 200,
'targetdate' => '',
'return_to_edit' => 1,
'reminder' => 'month',
'_token' => 'replaceMe'
];
// mock!
$piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
$piggyBanks->shouldReceive('update')->once()->andReturn($piggyBank);
$this->call('POST', '/piggy-banks/update/' . $piggyBank->id, $piggyBankData);
$this->assertResponseStatus(302);
}
}