mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 19:47:11 +00:00
Fix tests.
This commit is contained in:
@@ -61,8 +61,7 @@ class CurrencyMapperTest extends TestCase
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findNull')->once()->withArgs([$currency->id])->andReturn(null);
|
||||
$repository->shouldReceive('store')->once()
|
||||
->withArgs([['code' => null, 'name' => null, 'symbol' => null, 'decimal_places' => 2]])->andReturn(null);
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
@@ -161,9 +160,6 @@ class CurrencyMapperTest extends TestCase
|
||||
// mock data
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('store')->once()
|
||||
->withArgs([['code' => null, 'name' => null, 'symbol' => null, 'decimal_places' => 2]])->andReturn(null);
|
||||
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
@@ -148,6 +148,7 @@ class ImportableConverterTest extends TestCase
|
||||
$opposingMapper->shouldReceive('map')->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);
|
||||
|
||||
|
||||
$converter = new ImportableConverter;
|
||||
@@ -173,7 +174,7 @@ class ImportableConverterTest extends TestCase
|
||||
$importable = new ImportTransaction;
|
||||
$importable->amount = '45.67';
|
||||
$importable->date = '20180917';
|
||||
$importable->meta['date-book'] = '2018-01-02';
|
||||
$importable->meta['date-book'] = '20180102';
|
||||
$importables = [$importable];
|
||||
|
||||
$job = $this->user()->importJobs()->first();
|
||||
@@ -221,7 +222,7 @@ class ImportableConverterTest extends TestCase
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
$this->assertEquals($revenue->id, $result[0]['transactions'][0]['source_id']);
|
||||
$this->assertEquals($asset->id, $result[0]['transactions'][0]['destination_id']);
|
||||
$this->assertEquals($importable->meta['date-book'], $result[0]['book_date']);
|
||||
$this->assertEquals('2018-01-02', $result[0]['book_date']);
|
||||
|
||||
}
|
||||
|
||||
@@ -291,8 +292,8 @@ class ImportableConverterTest extends TestCase
|
||||
$importable = new ImportTransaction;
|
||||
$importable->amount = '45.67';
|
||||
$importable->date = '20180917';
|
||||
$importable->billId = 2; // will be ignored because it's not valid.
|
||||
$importable->billName = 'Some Bill'; // will be included because bill ID is not valid.
|
||||
$importable->billId = 2; // will NOT be ignored despite it's not valid.
|
||||
$importable->billName = 'Some Bill'; // will always be included even when bill ID is not valid.
|
||||
$importables = [$importable];
|
||||
|
||||
$job = $this->user()->importJobs()->first();
|
||||
@@ -337,7 +338,7 @@ class ImportableConverterTest extends TestCase
|
||||
$this->assertEquals('transfer', $result[0]['type']);
|
||||
$this->assertEquals('2018-09-17', $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertNull($result[0]['bill_id']);
|
||||
$this->assertEquals(2, $result[0]['bill_id']); // will NOT be ignored.
|
||||
$this->assertEquals($importable->billName, $result[0]['bill_name']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
// since amount is positive, $asset recieves the money
|
||||
@@ -357,7 +358,7 @@ class ImportableConverterTest extends TestCase
|
||||
$importable->amount = '-45.67';
|
||||
$importable->date = '20180917';
|
||||
$importable->billId = 3; // is added to array of valid values, see below.
|
||||
$importable->billName = 'Some bill'; // will be ignored because ID is valid.
|
||||
$importable->billName = 'Some bill'; // will be added even when ID is valid.
|
||||
$importables = [$importable];
|
||||
|
||||
$validMappings = [
|
||||
@@ -408,7 +409,7 @@ class ImportableConverterTest extends TestCase
|
||||
$this->assertEquals('2018-09-17', $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertEquals(3, $result[0]['bill_id']);
|
||||
$this->assertNull($result[0]['bill_name']);
|
||||
$this->assertEquals($importable->billName, $result[0]['bill_name']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
// since amount is negative, $asset sends the money
|
||||
$this->assertEquals($asset->id, $result[0]['transactions'][0]['source_id']);
|
||||
|
||||
Reference in New Issue
Block a user