Fix tests.

This commit is contained in:
James Cole 2019-08-12 17:36:37 +02:00
parent 76dad84ba6
commit 893c83e086
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 18 additions and 19 deletions

View File

@ -121,7 +121,7 @@ class ReconcileControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once(); //$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
$collector->shouldReceive('setAccounts')->atLeast()->once()->andReturnSelf(); $collector->shouldReceive('setAccounts')->atLeast()->once()->andReturnSelf();

View File

@ -144,8 +144,7 @@ class ImportableConverterTest extends TestCase
$currencyMapper = $this->mock(CurrencyMapper::class); $currencyMapper = $this->mock(CurrencyMapper::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('setUser')->once(); $accountRepos->shouldReceive('setUser')->once();
$accountRepos->shouldReceive('getMetaValue') $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn('1');
->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn('1');
// get default currency // get default currency
$euro = TransactionCurrency::whereCode('EUR')->first(); $euro = TransactionCurrency::whereCode('EUR')->first();
@ -162,12 +161,12 @@ class ImportableConverterTest extends TestCase
$asset = $this->user()->accounts()->where('account_type_id', 3)->first(); $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
$other = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $asset->id)->first(); $other = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $asset->id)->first();
$assetMapper->shouldReceive('map')->once()->withArgs([null, $nullAccount])->andReturn($asset); $assetMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, $nullAccount])->andReturn($asset);
$opposingMapper->shouldReceive('map')->once()->withArgs([null, '45.67', $nullAccount])->andReturn($other); $opposingMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, '45.67', $nullAccount])->andReturn($other);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn(null); $currencyMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn(null);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null); $currencyMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, ['code' => null]])->andReturn(null);
$currencyMapper->shouldReceive('map')->times(2)->withArgs([$euro->id, []])->andReturn($euro); $currencyMapper->shouldReceive('map')->atLeast()->once()->withArgs([$euro->id, []])->andReturn($euro);
$converter = new ImportableConverter; $converter = new ImportableConverter;
@ -226,8 +225,8 @@ class ImportableConverterTest extends TestCase
$asset = $this->user()->accounts()->where('account_type_id', 3)->first(); $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first(); $revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
$assetMapper->shouldReceive('map')->once()->withArgs([null, $nullAccount])->andReturn($asset); $assetMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, $nullAccount])->andReturn($asset);
$opposingMapper->shouldReceive('map')->once()->withArgs([null, '45.67', $nullAccount])->andReturn($revenue); $opposingMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, '45.67', $nullAccount])->andReturn($revenue);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null);
@ -289,8 +288,8 @@ class ImportableConverterTest extends TestCase
// respond to mapping call: // respond to mapping call:
$asset = $this->user()->accounts()->where('account_type_id', 3)->first(); $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
$assetMapper->shouldReceive('map')->once()->withArgs([null, $nullAccount])->andReturn($asset); $assetMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, $nullAccount])->andReturn($asset);
$opposingMapper->shouldReceive('map')->once()->withArgs([null, '-45.67', $nullAccount])->andReturn($asset); $opposingMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, '-45.67', $nullAccount])->andReturn($asset);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null);
$repository->shouldReceive('addErrorMessage')->withArgs( $repository->shouldReceive('addErrorMessage')->withArgs(
@ -349,8 +348,8 @@ class ImportableConverterTest extends TestCase
$asset = $this->user()->accounts()->where('account_type_id', 3)->first(); $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
$other = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $asset->id)->first(); $other = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $asset->id)->first();
$assetMapper->shouldReceive('map')->once()->withArgs([null, $nullAccount])->andReturn($asset); $assetMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, $nullAccount])->andReturn($asset);
$opposingMapper->shouldReceive('map')->once()->withArgs([null, '45.67', $nullAccount])->andReturn($other); $opposingMapper->shouldReceive('map')->atLeast()->once()->withArgs([null, '45.67', $nullAccount])->andReturn($other);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn($usd);
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null); $currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null);