From c5cdd748fc194056e654d64f1401f62c43ba5832 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 20 Aug 2017 14:36:14 +0200 Subject: [PATCH] Make sure tests work again. --- tests/Feature/Controllers/TagControllerTest.php | 4 +--- .../Controllers/Transaction/SplitControllerTest.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.php index dcfbe0bc13..7e1c5c8e76 100644 --- a/tests/Feature/Controllers/TagControllerTest.php +++ b/tests/Feature/Controllers/TagControllerTest.php @@ -102,13 +102,11 @@ class TagControllerTest extends TestCase public function testIndex() { // mock stuff - $tag = factory(Tag::class)->make(); $repository = $this->mock(TagRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $repository->shouldReceive('count')->andReturn(0); - $repository->shouldReceive('getByType')->andReturn(new Collection([$tag])); - + $repository->shouldReceive('tagCloud')->andReturn([]); $this->be($this->user()); $response = $this->get(route('tags.index')); diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.php index c430a30dde..f9ce7bbc1e 100644 --- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php +++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php @@ -47,17 +47,19 @@ class SplitControllerTest extends TestCase $currencyRepository = $this->mock(CurrencyRepositoryInterface::class); $accountRepository = $this->mock(AccountRepositoryInterface::class); $budgetRepository = $this->mock(BudgetRepositoryInterface::class); + $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); + $destination = $deposit->transactions()->where('amount', '>', 0)->first(); + $account = $destination->account; $transactions = factory(Transaction::class, 3)->make(); $tasker = $this->mock(JournalTaskerInterface::class); $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection); $accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]]) - ->andReturn(new Collection)->once(); + ->andReturn(new Collection([$account]))->once(); $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection); $tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray()); - $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); $this->be($this->user()); $response = $this->get(route('transactions.split.edit', [$deposit->id])); $response->assertStatus(200); @@ -90,15 +92,17 @@ class SplitControllerTest extends TestCase $budgetRepository = $this->mock(BudgetRepositoryInterface::class); $transactions = factory(Transaction::class, 1)->make(); $tasker = $this->mock(JournalTaskerInterface::class); + $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); + $destination = $deposit->transactions()->where('amount', '>', 0)->first(); + $account = $destination->account; $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection); $accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]]) - ->andReturn(new Collection)->once(); + ->andReturn(new Collection([$account]))->once(); $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection); $tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray()); - $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); $this->be($this->user()); $response = $this->get(route('transactions.split.edit', [$deposit->id])); $response->assertStatus(200);