From 02370fb65d7526d1ca017c83e816941055dfc392 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 1 Sep 2018 20:45:05 +0200 Subject: [PATCH] Fix final tests --- app/TransactionRules/TransactionMatcher.php | 43 ++++++------- .../Recurring/CreateControllerTest.php | 61 +++++++++++++++++-- 2 files changed, 79 insertions(+), 25 deletions(-) diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php index 5e2d5c9609..cd901335ae 100644 --- a/app/TransactionRules/TransactionMatcher.php +++ b/app/TransactionRules/TransactionMatcher.php @@ -48,35 +48,18 @@ class TransactionMatcher private $range = 200; /** @var Rule The rule to apply */ private $rule; + /** @var bool */ + private $strict; /** @var array Types that can be matched using this matcher */ private $transactionTypes = [TransactionType::DEPOSIT, TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; /** @var array List of triggers to match */ private $triggers = []; - /** @var bool */ - private $strict; public function __construct() { $this->strict = false; } - /** - * @return bool - */ - public function isStrict(): bool - { - return $this->strict; - } - - /** - * @param bool $strict - */ - public function setStrict(bool $strict): void - { - $this->strict = $strict; - } - - /** * This method will search the user's transaction journal (with an upper limit of $range) for * transaction journals matching the given rule. This is accomplished by trying to fire these @@ -92,8 +75,10 @@ class TransactionMatcher } // Variables used within the loop - $processor = Processor::make($this->rule, false); - $result = $this->runProcessor($processor); + /** @var Processor $processor */ + $processor = app(Processor::class); + $processor->make($this->rule, false); + $result = $this->runProcessor($processor); // If the list of matchingTransactions is larger than the maximum number of results // (e.g. if a large percentage of the transactions match), truncate the list @@ -202,6 +187,22 @@ class TransactionMatcher return $this; } + /** + * @return bool + */ + public function isStrict(): bool + { + return $this->strict; + } + + /** + * @param bool $strict + */ + public function setStrict(bool $strict): void + { + $this->strict = $strict; + } + /** * Set rule * diff --git a/tests/Feature/Controllers/Recurring/CreateControllerTest.php b/tests/Feature/Controllers/Recurring/CreateControllerTest.php index d91be2f808..c75543fe52 100644 --- a/tests/Feature/Controllers/Recurring/CreateControllerTest.php +++ b/tests/Feature/Controllers/Recurring/CreateControllerTest.php @@ -24,8 +24,10 @@ declare(strict_types=1); namespace Tests\Feature\Controllers\Recurring; +use Carbon\Carbon; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; +use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface; use Illuminate\Support\Collection; use Log; @@ -46,10 +48,13 @@ class CreateControllerTest extends TestCase Log::debug(sprintf('Now in %s.', \get_class($this))); } - public function testCreate() { - $recurringRepos =$this->mock(RecurringRepositoryInterface::class); - $budgetRepos = $this->mock(BudgetRepositoryInterface::class); - + /** + * @covers \FireflyIII\Http\Controllers\Recurring\CreateController + */ + public function testCreate(): void + { + $recurringRepos = $this->mock(RecurringRepositoryInterface::class); + $budgetRepos = $this->mock(BudgetRepositoryInterface::class); $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once(); \Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(1)); @@ -59,4 +64,52 @@ class CreateControllerTest extends TestCase $response->assertStatus(200); $response->assertSee('