From 04b2eaf53539819518003e60381af3675717aae9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 9 Mar 2018 06:46:45 +0100 Subject: [PATCH] Fix tests that broke during Laravel 5.6 upgrade --- .../Controllers/ExportControllerTest.php | 3 +- .../Controllers/Json/BoxControllerTest.php | 4 +- .../Controllers/PreferencesControllerTest.php | 139 ------------------ .../Controllers/ProfileControllerTest.php | 66 +++++++++ .../Report/ExpenseControllerTest.php | 2 + tests/Unit/Middleware/AuthenticateTest.php | 2 +- 6 files changed, 73 insertions(+), 143 deletions(-) diff --git a/tests/Feature/Controllers/ExportControllerTest.php b/tests/Feature/Controllers/ExportControllerTest.php index 480a58b73f..0fae59774e 100644 --- a/tests/Feature/Controllers/ExportControllerTest.php +++ b/tests/Feature/Controllers/ExportControllerTest.php @@ -102,8 +102,9 @@ class ExportControllerTest extends TestCase $repository = $this->mock(ExportJobRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); + $job = ExportJob::first(); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - $repository->shouldReceive('create')->andReturn(new ExportJob); + $repository->shouldReceive('create')->andReturn($job); $repository->shouldReceive('cleanup'); $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection); diff --git a/tests/Feature/Controllers/Json/BoxControllerTest.php b/tests/Feature/Controllers/Json/BoxControllerTest.php index 19449b1d62..40ce31cea0 100644 --- a/tests/Feature/Controllers/Json/BoxControllerTest.php +++ b/tests/Feature/Controllers/Json/BoxControllerTest.php @@ -100,7 +100,7 @@ class BoxControllerTest extends TestCase { $accountRepos = $this->mock(AccountRepositoryInterface::class); $currencyRepos = $this->mock(CurrencyRepositoryInterface::class); - $accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()])); + $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()])); $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1)); $this->be($this->user()); $response = $this->get(route('json.box.net-worth')); @@ -114,7 +114,7 @@ class BoxControllerTest extends TestCase { $accountRepos = $this->mock(AccountRepositoryInterface::class); $currencyRepos = $this->mock(CurrencyRepositoryInterface::class); - $accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()])); + $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()])); $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1)); $start = new Carbon; diff --git a/tests/Feature/Controllers/PreferencesControllerTest.php b/tests/Feature/Controllers/PreferencesControllerTest.php index 749b162a4a..7aef05dbd8 100644 --- a/tests/Feature/Controllers/PreferencesControllerTest.php +++ b/tests/Feature/Controllers/PreferencesControllerTest.php @@ -41,41 +41,6 @@ use Tests\TestCase; */ class PreferencesControllerTest extends TestCase { - /** - * @covers \FireflyIII\Http\Controllers\PreferencesController::code - * @covers \FireflyIII\Http\Controllers\PreferencesController::getDomain - */ - public function testCode() - { - // mock stuff - $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - Google2FA::shouldReceive('generateSecretKey')->andReturn('secret'); - Google2FA::shouldReceive('getQRCodeInline')->andReturn('long-data-url'); - - $this->be($this->user()); - $response = $this->get(route('preferences.code')); - $response->assertStatus(200); - $response->assertSee('