From 71104f375cfbdf8a032da949536e8c8da1768260 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 10 Feb 2019 14:33:03 +0100 Subject: [PATCH] Fix tests --- app/Http/Controllers/Admin/ConfigurationController.php | 1 + app/TransactionRules/Actions/ConvertToTransfer.php | 2 +- tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php | 2 +- tests/Unit/Import/Storage/ImportArrayStorageTest.php | 5 ++--- .../JobConfiguration/Spectre/ChooseAccountsHandlerTest.php | 4 ++-- .../Unit/TransactionRules/Actions/ConvertToTransferTest.php | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index 1c01a16727..159b717e3b 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -29,6 +29,7 @@ use FireflyIII\Http\Middleware\IsSandStormUser; use FireflyIII\Http\Requests\ConfigurationRequest; use FireflyIII\Support\Facades\FireflyConfig; use Illuminate\Http\RedirectResponse; +use Log; /** * Class ConfigurationController. diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php index 5570187836..6194cc8a24 100644 --- a/app/TransactionRules/Actions/ConvertToTransfer.php +++ b/app/TransactionRules/Actions/ConvertToTransfer.php @@ -73,7 +73,7 @@ class ConvertToTransfer implements ActionInterface $repository = app(AccountRepositoryInterface::class); $repository->setUser($journal->user); $asset = $repository->findByName( - $this->action->action_value, [AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE] + $this->action->action_value, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE] ); if (null === $asset) { // @codeCoverageIgnoreStart diff --git a/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php b/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php index 24c7be88a6..4f9ee3ec14 100644 --- a/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php +++ b/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php @@ -74,7 +74,7 @@ class VersionCheckEventHandlerTest extends TestCase // request thing: $request->shouldReceive('call')->once()->andThrow(new FireflyException('Errrr')); - $request->shouldReceive('getReleases')->once(); + $request->shouldNotReceive('getReleases'); $handler = new VersionCheckEventHandler; diff --git a/tests/Unit/Import/Storage/ImportArrayStorageTest.php b/tests/Unit/Import/Storage/ImportArrayStorageTest.php index 6f1a224dc5..77bf608492 100644 --- a/tests/Unit/Import/Storage/ImportArrayStorageTest.php +++ b/tests/Unit/Import/Storage/ImportArrayStorageTest.php @@ -125,7 +125,6 @@ class ImportArrayStorageTest extends TestCase $transactions = [$this->singleTransfer(), $this->singleWithdrawal(), $this->basedOnTransfer($transfer)]; $job->save(); - // get some stuff: $tag = $this->user()->tags()->inRandomOrder()->first(); $journal = $this->user()->transactionJournals()->inRandomOrder()->first(); @@ -141,9 +140,9 @@ class ImportArrayStorageTest extends TestCase $ruleRepos = $this->mock(RuleRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $repository->shouldReceive('getTransactions')->times(2)->andReturn($transactions); + // mock calls: $collector->shouldReceive('setUser')->times(2); - $repository->shouldReceive('setUser')->once(); $repository->shouldReceive('setStatus')->withAnyArgs(); $ruleRepos->shouldReceive('setUser')->once(); @@ -554,7 +553,7 @@ class ImportArrayStorageTest extends TestCase return [ 'type' => 'transfer', - 'date' => $transfer->date->format('Y-m-d'), + 'date' => $transfer->date->format('Y-m-d H:i:s'), 'tags' => '', 'user' => $this->user()->id, diff --git a/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandlerTest.php b/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandlerTest.php index 03f9122029..3a89f61838 100644 --- a/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandlerTest.php +++ b/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandlerTest.php @@ -472,7 +472,7 @@ class ChooseAccountsHandlerTest extends TestCase $usd = TransactionCurrency::where('code', 'USD')->first(); $first = $this->user()->accounts()->where('account_type_id', 3)->first(); $second = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $first->id)->first(); - $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]]) + $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]]) ->once()->andReturn(new Collection([$first, $second])); $accountRepos->shouldReceive('getMetaValue')->twice()->withArgs([Mockery::any(), 'currency_id']) ->andReturn(1, 2); @@ -625,7 +625,7 @@ class ChooseAccountsHandlerTest extends TestCase $usd = TransactionCurrency::where('code', 'USD')->first(); $first = $this->user()->accounts()->where('account_type_id', 3)->first(); $second = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $first->id)->first(); - $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]]) + $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]]) ->once()->andReturn(new Collection([$first, $second])); $accountRepos->shouldReceive('getMetaValue')->twice()->withArgs([Mockery::any(), 'currency_id']) ->andReturn(1, 2); diff --git a/tests/Unit/TransactionRules/Actions/ConvertToTransferTest.php b/tests/Unit/TransactionRules/Actions/ConvertToTransferTest.php index 4af99c4a80..ce7ceed90d 100644 --- a/tests/Unit/TransactionRules/Actions/ConvertToTransferTest.php +++ b/tests/Unit/TransactionRules/Actions/ConvertToTransferTest.php @@ -65,7 +65,7 @@ class ConvertToTransferTest extends TestCase // mock used stuff: $accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos->shouldReceive('setUser')->once(); - $accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::DEFAULT]])->andReturn($asset); + $accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])->andReturn($asset); // fire the action: $ruleAction = new RuleAction; @@ -100,7 +100,7 @@ class ConvertToTransferTest extends TestCase // mock used stuff: $accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos->shouldReceive('setUser')->once(); - $accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::DEFAULT]])->andReturn($asset); + $accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])->andReturn($asset); // fire the action: $ruleAction = new RuleAction;