Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix final tests
James Cole02370fb65d75
diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.phpindex 5e2d5c9609..cd901335ae 100644--- a/app/TransactionRules/TransactionMatcher.php+++ b/app/TransactionRules/TransactionMatcher.php@@ -48,35 +48,18 @@ class TransactionMatcherprivate $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 TransactionMatcherreturn $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.phpindex 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 TestCaseLog::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('<ol class="breadcrumb">');}++ /**+ * @covers \FireflyIII\Http\Controllers\Recurring\CreateController+ * @covers \FireflyIII\Http\Requests\RecurrenceFormRequest+ */+ public function testStore(): void+ {+ $recurringRepos = $this->mock(RecurringRepositoryInterface::class);+ $budgetRepos = $this->mock(BudgetRepositoryInterface::class);+ $categoryRepos = $this->mock(CategoryRepositoryInterface::class);+ $tomorrow = Carbon::create()->addDays(2);+ $recurrence = $this->user()->recurrences()->first();+ $data = [+ 'title' => 'hello',+ 'first_date' => $tomorrow->format('Y-m-d'),+ 'repetition_type' => 'daily',+ 'skip' => 0,+ 'recurring_description' => 'Some descr',+ 'active' => '1',+ 'apply_rules' => '1',++ // mandatory for transaction:+ 'transaction_description' => 'Some descr',+ 'transaction_type' => 'withdrawal',+ 'transaction_currency_id' => '1',+ 'amount' => '30',+ // mandatory account info:+ 'source_id' => '1',+ 'source_name' => '',+ 'destination_id' => '',+ 'destination_name' => 'Some Expense',++ // optional fields:+ 'budget_id' => '1',+ 'category' => 'CategoryA',+ 'tags' => 'A,B,C',++ 'repetition_end' => 'times',+ 'repetitions' => 3,+ ];++ $recurringRepos->shouldReceive('store')->andReturn($recurrence)->once();++ $this->be($this->user());+ $response = $this->post(route('recurring.store'), $data);+ $response->assertStatus(302);+ $response->assertSessionHas('success');+ }}\ No newline at end of file