mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Improve test coverage.
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Tests\Unit\Console\Commands\Tools;
|
||||
|
||||
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
@@ -31,6 +32,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -100,6 +103,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -159,6 +167,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('No rules or rule groups have been included.')
|
||||
->expectsOutput('Done!')
|
||||
@@ -218,6 +231,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--end_date=2019-01-01',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -281,6 +299,11 @@ class ApplyRulesTest extends TestCase
|
||||
sprintf('--rules=%d,%d', $activeRule->id, $inactiveRule->id),
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -343,6 +366,11 @@ class ApplyRulesTest extends TestCase
|
||||
sprintf('--rule_groups=%d,%d', $activeGroup->id, $inactiveGroup->id),
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput(sprintf('Will ignore inactive rule group #%d ("%s")', $inactiveGroup->id, $inactiveGroup->title))
|
||||
// one rule out of 2 groups:
|
||||
@@ -379,6 +407,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Please use the --accounts option to indicate the accounts to apply rules to.')
|
||||
->assertExitCode(1);
|
||||
@@ -417,6 +450,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Please make sure all accounts in --accounts are asset accounts or liabilities.')
|
||||
->assertExitCode(1);
|
||||
|
Reference in New Issue
Block a user