Basic testing, not full coverage.

This commit is contained in:
James Cole
2014-08-19 13:24:11 +02:00
parent f5330728d4
commit f00dfd2859
17 changed files with 325 additions and 162 deletions

View File

@@ -65,7 +65,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.change');
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(true);
$this->action('POST', 'BudgetController@destroy', $budget->id);
@@ -81,7 +81,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.change');
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(true);
$this->action('POST', 'BudgetController@destroy', [$budget->id, 'from' => 'date']);
@@ -97,7 +97,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.change');
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(false);
@@ -233,7 +233,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
$this->_repository->shouldReceive('update')->andReturn($budget);
Event::shouldReceive('fire')->with('budgets.change');
Event::shouldReceive('fire')->with('budgets.update',[$budget]);
$this->action('POST', 'BudgetController@update', $budget->id);
$this->assertRedirectedToRoute('budgets.index.budget');
@@ -248,7 +248,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
$this->_repository->shouldReceive('update')->andReturn($budget);
Event::shouldReceive('fire')->with('budgets.change');
Event::shouldReceive('fire')->with('budgets.update',[$budget]);
//$this->_user->shouldReceive('budgets')->andReturn([]); // trigger
$this->action('POST', 'BudgetController@update', [$budget->id, 'from' => 'date']);

View File

@@ -175,6 +175,8 @@ class LimitControllerTest extends TestCase
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($limit->budget()->first()->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_limits->shouldReceive('update')->once()->andReturn($limit);
$this->action(
'POST', 'LimitController@update',
@@ -200,6 +202,9 @@ class LimitControllerTest extends TestCase
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($limit->budget()->first()->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
unset($limit->amount);
$this->_limits->shouldReceive('update')->once()->andReturn($limit);
$this->action(
'POST', 'LimitController@update',
@@ -219,6 +224,8 @@ class LimitControllerTest extends TestCase
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($limit->budget()->first()->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_limits->shouldReceive('update')->once()->andReturn($limit);
$this->action(
'POST', 'LimitController@update',

View File

@@ -92,7 +92,7 @@ class PiggybankControllerTest extends TestCase
);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_piggybanks->shouldReceive('destroy')->andReturn(true);
Event::shouldReceive('fire')->with('piggybanks.change');
Event::shouldReceive('fire')->with('piggybanks.destroy', [$piggyBank]);
$this->action('POST', 'PiggybankController@destroy', $piggyBank->id);
@@ -114,6 +114,7 @@ class PiggybankControllerTest extends TestCase
);
$this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn('some@email');
$this->action('GET', 'PiggybankController@edit', $piggyBank->id);
$this->assertResponseOk();
}
@@ -153,6 +154,7 @@ class PiggybankControllerTest extends TestCase
$three->account()->associate($aTwo);
$this->_piggybanks->shouldReceive('get')->andReturn([$one, $two, $three]);
$this->_piggybanks->shouldReceive('countRepeating')->andReturn(0);
$this->_piggybanks->shouldReceive('leftOnAccount')->andReturn(0);
$this->_piggybanks->shouldReceive('countNonrepeating')->andReturn(0);
Event::shouldReceive('fire')->with('piggybanks.change');
@@ -169,7 +171,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'add'
'what' => 'add'
];
// for binding
@@ -179,7 +181,7 @@ class PiggybankControllerTest extends TestCase
$piggyBank->account()->first()->user_id
);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
Event::shouldReceive('fire')->with('piggybanks.change');
Event::shouldReceive('fire');//->with('piggybanks.modifyAmountAdd', [$piggyBank, 10.0]);
$this->_piggybanks->shouldReceive('modifyAmount')->once();
$this->_piggybanks->shouldReceive('leftOnAccount')->once()->andReturn(200);
@@ -199,7 +201,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'add'
'what' => 'add'
];
// for binding
@@ -207,7 +209,7 @@ class PiggybankControllerTest extends TestCase
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');
Event::shouldReceive('fire')->with('piggybanks.change');
Event::shouldReceive('fire')->with('piggybanks.modifyAmountAdd', [$piggyBank, -10.0]);
$this->_piggybanks->shouldReceive('leftOnAccount')->once()->andReturn(5);
@@ -228,7 +230,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'yomoma'
'what' => 'yomoma'
];
// for binding
@@ -267,7 +269,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$rep->piggybank()->first()->id,
'amount' => 10.0,
'what' => 'remove'
'what' => 'remove'
];
$this->action('POST', 'PiggybankController@modMoney', $input);
@@ -297,7 +299,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$rep->piggybank()->first()->id,
'amount' => 10.0,
'what' => 'remove'
'what' => 'remove'
];
$this->action('POST', 'PiggybankController@modMoney', $input);
@@ -391,7 +393,7 @@ class PiggybankControllerTest extends TestCase
$piggyBank->account()->first()->user_id
);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
Event::shouldReceive('fire')->with('piggybanks.change');
Event::shouldReceive('fire')->with('piggybanks.update',[$piggyBank]);
$this->action('POST', 'PiggybankController@update', $piggyBank->id);
$this->assertResponseStatus(302);

View File

@@ -123,6 +123,8 @@ class TransactionControllerTest extends TestCase
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($journal->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_piggies->shouldReceive('get')->once()->andReturn([]);
$this->action('GET', 'TransactionController@edit', $journal->id);
$this->assertResponseOk();
}
@@ -152,6 +154,8 @@ class TransactionControllerTest extends TestCase
$this->_accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
$this->_budgets->shouldReceive('getAsSelectList')->andReturn([]);
$this->_piggies->shouldReceive('get')->once()->andReturn([]);
// for binding
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
@@ -186,6 +190,7 @@ class TransactionControllerTest extends TestCase
$this->_accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
$this->_budgets->shouldReceive('getAsSelectList')->andReturn([]);
$this->_piggies->shouldReceive('get')->once()->andReturn([]);
// for binding
Auth::shouldReceive('user')->andReturn($this->_user);