Fix some tests.

This commit is contained in:
James Cole
2020-07-17 18:51:54 +02:00
parent cd65d4d4c5
commit f14ac5928f
3 changed files with 29 additions and 48 deletions

View File

@@ -154,17 +154,6 @@ class ApplyRulesTest extends TestCase
$ruleGroupRepos->shouldReceive('getActiveGroups')->atLeast()->once()->andReturn($groups); $ruleGroupRepos->shouldReceive('getActiveGroups')->atLeast()->once()->andReturn($groups);
$ruleGroupRepos->shouldReceive('getActiveStoreRules')->atLeast()->once()->andReturn(new Collection); $ruleGroupRepos->shouldReceive('getActiveStoreRules')->atLeast()->once()->andReturn(new Collection);
$collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setAccounts')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn([[], [], []]);
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
$ruleEngine->shouldReceive('setRulesToApply')->atLeast()->once();
$ruleEngine->shouldReceive('processJournalArray')->times(3);
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once()->withArgs([RuleEngine::TRIGGER_STORE]);
$parameters = [ $parameters = [
'--user=1', '--user=1',
'--token=token', '--token=token',
@@ -179,8 +168,7 @@ class ApplyRulesTest extends TestCase
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters)) $this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
->expectsOutput('No rules or rule groups have been included.') ->expectsOutput('No rules or rule groups have been included.')
->expectsOutput('Done!') ->assertExitCode(1);
->assertExitCode(0);
} }

View File

@@ -81,13 +81,14 @@ class OtherCurrenciesCorrectionsTest extends TestCase
// account repos // account repos
$accountRepos->shouldReceive('setUser')->atLeast()->once(); $accountRepos->shouldReceive('setUser')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->atLeast()->once() $accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1'); #$accountRepos->shouldReceive('getMetaValue')->atLeast()->once()
# ->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
// collect currency // collect currency
$currencyRepos->shouldReceive('setUser')->atLeast()->once(); $currencyRepos->shouldReceive('setUser')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->atLeast()->once() #$currencyRepos->shouldReceive('findNull')->atLeast()->once()
->withArgs([1])->andReturn($euro); # ->withArgs([1])->andReturn($euro);
// configuration // configuration
$false = new Configuration; $false = new Configuration;
@@ -157,13 +158,12 @@ class OtherCurrenciesCorrectionsTest extends TestCase
// account repos // account repos
$accountRepos->shouldReceive('setUser')->atLeast()->once(); $accountRepos->shouldReceive('setUser')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->atLeast()->once() $accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
// collect currency // collect currency
$currencyRepos->shouldReceive('setUser')->atLeast()->once(); $currencyRepos->shouldReceive('setUser')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->atLeast()->once() #$currencyRepos->shouldReceive('findNull')->atLeast()->once()
->withArgs([1])->andReturn($euro); # ->withArgs([1])->andReturn($euro);
// configuration // configuration
$false = new Configuration; $false = new Configuration;
@@ -242,13 +242,13 @@ class OtherCurrenciesCorrectionsTest extends TestCase
// account repos // account repos
$accountRepos->shouldReceive('setUser')->atLeast()->once(); $accountRepos->shouldReceive('setUser')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->atLeast()->once() #$accountRepos->shouldReceive('getMetaValue')->atLeast()->once()
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1'); # ->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
// collect currency // collect currency
$currencyRepos->shouldReceive('setUser')->atLeast()->once(); $currencyRepos->shouldReceive('setUser')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->atLeast()->once() #$currencyRepos->shouldReceive('findNull')->atLeast()->once()
->withArgs([1])->andReturn($euro); # ->withArgs([1])->andReturn($euro);
// configuration // configuration
$false = new Configuration; $false = new Configuration;

View File

@@ -106,14 +106,15 @@ class TransferCurrenciesCorrectionsTest extends TestCase
->atLeast()->once()->andReturn(new Collection([$transfer])); ->atLeast()->once()->andReturn(new Collection([$transfer]));
// account repos // account repos
$accountRepos->shouldReceive('getMetaValue') #$accountRepos->shouldReceive('getMetaValue')
->atLeast()->once() # ->atLeast()->once()
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1'); # ->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
// currency repos // currency repos
$currencyRepos->shouldReceive('findNull') #$currencyRepos->shouldReceive('findNull')
->atLeast()->once() # ->atLeast()->once()
->withArgs([1])->andReturn($euro); # ->withArgs([1])->andReturn($euro);
// configuration // configuration
$false = new Configuration; $false = new Configuration;
@@ -151,14 +152,15 @@ class TransferCurrenciesCorrectionsTest extends TestCase
->atLeast()->once()->andReturn(new Collection([$transfer])); ->atLeast()->once()->andReturn(new Collection([$transfer]));
// account repos // account repos
$accountRepos->shouldReceive('getMetaValue') #$accountRepos->shouldReceive('getMetaValue')
->atLeast()->once() # ->atLeast()->once()
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1'); # ->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
// currency repos // currency repos
$currencyRepos->shouldReceive('findNull') #$currencyRepos->shouldReceive('findNull')
->atLeast()->once() # ->atLeast()->once()
->withArgs([1])->andReturn($euro); # ->withArgs([1])->andReturn($euro);
// configuration // configuration
$false = new Configuration; $false = new Configuration;
@@ -202,16 +204,7 @@ class TransferCurrenciesCorrectionsTest extends TestCase
->withArgs([[TransactionType::TRANSFER]]) ->withArgs([[TransactionType::TRANSFER]])
->atLeast()->once()->andReturn(new Collection([$transfer])); ->atLeast()->once()->andReturn(new Collection([$transfer]));
// account repos $accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
$accountRepos->shouldReceive('getMetaValue')
->atLeast()->once()
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1', $dollar->id);
// currency repos
$currencyRepos->shouldReceive('findNull')
->atLeast()->once()
->withArgs([1])->andReturn($euro);
$currencyRepos->shouldReceive('findNull') $currencyRepos->shouldReceive('findNull')
->atLeast()->once() ->atLeast()->once()
->withArgs([$dollar->id])->andReturn($dollar); ->withArgs([$dollar->id])->andReturn($dollar);