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

@ -164,16 +164,16 @@ class BillControllerTest extends TestCase
$repository = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$transformer = $this->mock(BillTransformer::class);
$euro = $this->getEuro();
$pref = new Preference;
$pref->data = 50;
$euro = $this->getEuro();
$pref = new Preference;
$pref->data = 50;
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
Amount::shouldReceive('formatAnything')->andReturn('-100');
$transformer->shouldReceive('setParameters')->atLeast()->once();
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
'currency' => $this->getEuro(),
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
'currency' => $this->getEuro(),
'currency_id' => $euro->id,
'currency_code' => $euro->code,
'currency_symbol' => $euro->symbol,

View File

@ -121,7 +121,7 @@ class ReconcileControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->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();

View File

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