Improve test coverage.

This commit is contained in:
James Cole
2019-08-03 10:50:43 +02:00
parent b8b59b13a7
commit 75c2529d3e
23 changed files with 367 additions and 539 deletions

View File

@@ -68,16 +68,18 @@ class PiggyBankEventTransformerTest extends TestCase
// mock calls:
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn(1);
$currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn($this->getEuro());
$piggyRepos->shouldReceive('getTransactionWithEvent')->atLeast()->once()->andReturn(123);
$event = PiggyBankEvent::first();
$event = $this->getRandomPiggyBankEvent();
$transformer = app(PiggyBankEventTransformer::class);
$transformer->setParameters(new ParameterBag);
$result = $transformer->transform($event);
$this->assertEquals($event->id, $result['id']);
$this->assertEquals(245, $result['amount']);
$this->assertEquals(123, $result['transaction_id']);
$this->assertEquals($event->amount, $result['amount']);
$this->assertEquals($event->transaction_journal_id, $result['transaction_journal_id']);
}
@@ -100,18 +102,17 @@ class PiggyBankEventTransformerTest extends TestCase
// mock calls:
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn(1);
$currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn(null);
$piggyRepos->shouldReceive('getTransactionWithEvent')->atLeast()->once()->andReturn(123);
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->atLeast()->once();
$event = PiggyBankEvent::first();
$event = $this->getRandomPiggyBankEvent();
$transformer = app(PiggyBankEventTransformer::class);
$transformer->setParameters(new ParameterBag);
$result = $transformer->transform($event);
$this->assertEquals($event->id, $result['id']);
$this->assertEquals(245, $result['amount']);
$this->assertEquals(123, $result['transaction_id']);
$this->assertEquals($event->amount, $result['amount']);
$this->assertEquals($event->transaction_journal_id, $result['transaction_journal_id']);
}
}