Fix tests to catch use of repositories

This commit is contained in:
James Cole
2018-03-07 10:18:50 +01:00
parent 7109fd8196
commit e2d1de94b7
2 changed files with 33 additions and 7 deletions

View File

@@ -2377,9 +2377,13 @@ class TransactionControllerTest extends TestCase
*/
public function testUpdateBasicDeposit()
{
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$data = [
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$account->id]])->andReturn(new Collection([$account]));
$data = [
'description' => 'Some deposit #' . rand(1, 1000),
'date' => '2018-01-01',
'transactions' => [
@@ -2416,6 +2420,11 @@ class TransactionControllerTest extends TestCase
{
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$account->id]])->andReturn(new Collection([$account]));
$data = [
'description' => 'Some transaction #' . rand(1, 1000),
'date' => '2018-01-01',
@@ -2433,6 +2442,8 @@ class TransactionControllerTest extends TestCase
$count = $withdrawal->transactions()->count();
} while ($count !== 2);
$transaction = $withdrawal->transactions()->first();
$repository->shouldReceive('setUser');
$repository->shouldReceive('update')->andReturn($withdrawal)->once();