Improve test coverage.

This commit is contained in:
James Cole
2019-08-29 17:53:25 +02:00
parent 91b6b86202
commit 19feefda2d
86 changed files with 3173 additions and 2626 deletions

View File

@@ -63,6 +63,8 @@ class ConfigureMappingHandlerTest extends TestCase
public function testApplySpecifics(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -145,6 +147,7 @@ class ConfigureMappingHandlerTest extends TestCase
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
// run configure mapping handler.
// expect specific results:
@@ -165,6 +168,7 @@ class ConfigureMappingHandlerTest extends TestCase
public function testDoColumnConfig(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -230,6 +234,8 @@ class ConfigureMappingHandlerTest extends TestCase
public function testDoMapOfColumn(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -343,6 +349,8 @@ class ConfigureMappingHandlerTest extends TestCase
public function testGetPreProcessorName(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -422,6 +430,8 @@ class ConfigureMappingHandlerTest extends TestCase
public function testGetValuesForMapping(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
// create a reader to use in method.
// 5 columns, of which #4 (index 3) is budget-id
@@ -490,6 +500,7 @@ class ConfigureMappingHandlerTest extends TestCase
*/
public function testSanitizeColumnName(): void
{
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$importRepos->shouldReceive('setUser')->once();
$job = new ImportJob;

View File

@@ -61,7 +61,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testConfigurationCompleteBasic(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-count' => 5,
@@ -84,6 +84,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testConfigurationCompleteForeign(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-count' => 5,
@@ -110,6 +111,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testConfigurationCompleteNoAmount(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-count' => 5,
'column-roles' => [
@@ -173,6 +175,7 @@ class ConfigureRolesHandlerTest extends TestCase
];
$repository = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('setStage')->once()->withArgs([Mockery::any(), 'ready_to_run']);
$repository->shouldReceive('setStage')->once()->withArgs([Mockery::any(), 'map']);
@@ -189,6 +192,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testGetExampleFromLine(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$lines = [
['one', 'two', '', 'three'],
['four', 'five', '', 'six'],
@@ -212,6 +216,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testGetExamplesFromFile(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$importRepos->shouldReceive('setUser')->once();
$importRepos->shouldReceive('setConfiguration')->once()
->withAnyArgs();
@@ -255,6 +260,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testGetHeadersHas(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
//$importRepos->shouldReceive('setUser')->once();
// create a reader to use in method.
// 5 columns, of which #4 (index 3) is budget-id
@@ -278,6 +284,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testGetHeadersNone(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
// create a reader to use in method.
// 5 columns, of which #4 (index 3) is budget-id
@@ -418,7 +425,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testIgnoreUnmappableColumns(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-count' => 5,
'column-roles' => [
@@ -463,6 +470,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testIsMappingNecessaryNo(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-do-mapping' => [false, false, false],
@@ -478,6 +486,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testIsMappingNecessaryYes(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$config = [
'column-do-mapping' => [false, true, false, false],
@@ -493,6 +502,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testMakeExamplesUnique(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$lines = [
['one', 'two', '', 'three'],
@@ -521,6 +531,7 @@ class ConfigureRolesHandlerTest extends TestCase
public function testProcessSpecifics(): void
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$line = [];
$config = [
@@ -555,6 +566,8 @@ class ConfigureRolesHandlerTest extends TestCase
$job->save();
$repository = $this->mock(ImportJobRepositoryInterface::class);
$helper = $this->mock(AttachmentHelperInterface::class);
$repository->shouldReceive('setUser');
$repository->shouldReceive('setConfiguration')->once()
->withArgs([Mockery::any(), ['column-count' => 0]]);

View File

@@ -162,7 +162,9 @@ class ConfigureUploadHandlerTest extends TestCase
$job->save();
$repository = $this->mock(ImportJobRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('setUser');
$accountRepos->shouldReceive('setUser');
$repository->shouldReceive('setConfiguration')->once()->withArgs([Mockery::any(), ['date-format' => 'Ymd']]);
$handler = new ConfigureUploadHandler;
@@ -181,6 +183,8 @@ class ConfigureUploadHandlerTest extends TestCase
*/
public function testGetSpecifics(): void
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$array = [
'specifics' => [
'IngDescription', 'BadFakeNewsThing',

View File

@@ -475,7 +475,7 @@ class ImportTransactionTest extends TestCase
$importTransaction = new ImportTransaction;
$importTransaction->amountDebit = '1.01';
try {
$this->assertEquals('-1.01', $importTransaction->calculateAmount());
$this->assertEquals('-1.010000000000', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
@@ -507,7 +507,7 @@ class ImportTransactionTest extends TestCase
$importTransaction->amount = '2.99';
$importTransaction->modifiers['generic-debit-credit'] = 'D';
try {
$this->assertEquals('-2.99', $importTransaction->calculateAmount());
$this->assertEquals('-2.990000000000', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
@@ -523,7 +523,7 @@ class ImportTransactionTest extends TestCase
$importTransaction = new ImportTransaction;
$importTransaction->amountNegated = '-1.56';
try {
$this->assertEquals('1.56', $importTransaction->calculateAmount());
$this->assertEquals('1.560000000000', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
@@ -539,7 +539,7 @@ class ImportTransactionTest extends TestCase
$importTransaction = new ImportTransaction;
$importTransaction->amountNegated = '1.56';
try {
$this->assertEquals('-1.56', $importTransaction->calculateAmount());
$this->assertEquals('-1.560000000000', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
@@ -556,7 +556,7 @@ class ImportTransactionTest extends TestCase
$importTransaction->amount = '-2.17';
$importTransaction->modifiers['rabo-debit-credit'] = 'C';
try {
$this->assertEquals('2.17', $importTransaction->calculateAmount());
$this->assertEquals('2.170000000000', $importTransaction->calculateAmount());
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
@@ -643,7 +643,7 @@ class ImportTransactionTest extends TestCase
$importTransaction = new ImportTransaction;
$importTransaction->foreignAmount = '6.77';
$importTransaction->modifiers['generic-debit-credit'] = 'D';
$this->assertEquals('-6.77', $importTransaction->calculateForeignAmount());
$this->assertEquals('-6.770000000000', $importTransaction->calculateForeignAmount());
}
/**
@@ -656,7 +656,7 @@ class ImportTransactionTest extends TestCase
$importTransaction = new ImportTransaction;
$importTransaction->foreignAmount = '-5.77';
$importTransaction->modifiers['generic-debit-credit'] = 'C';
$this->assertEquals('5.77', $importTransaction->calculateForeignAmount());
$this->assertEquals('5.770000000000', $importTransaction->calculateForeignAmount());
}
/**