Some code cleanup and fixes.

This commit is contained in:
James Cole
2014-08-10 11:30:14 +02:00
parent c50a9b4b04
commit fbd056104a
27 changed files with 145 additions and 91 deletions

View File

@@ -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');