Expand test coverage.

This commit is contained in:
James Cole
2019-07-26 17:48:24 +02:00
parent 6ff4a0b45c
commit d94d34ca63
57 changed files with 2243 additions and 1597 deletions

View File

@@ -88,7 +88,7 @@ class BunqJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'bunq_jc_B' . random_int(1, 10000);
$job->key = 'bunq_jc_B' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';
@@ -122,7 +122,7 @@ class BunqJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'bunq_jc_C' . random_int(1, 10000);
$job->key = 'bunq_jc_C' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';

View File

@@ -57,7 +57,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'A_unit_' . random_int(1, 10000);
$job->key = 'A_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -84,7 +84,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'B_unit_' . random_int(1, 10000);
$job->key = 'B_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'needs_config';
$job->provider = 'fake';
@@ -110,7 +110,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'C_unit_' . random_int(1, 10000);
$job->key = 'C_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -138,7 +138,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'D_unit_' . random_int(1, 10000);
$job->key = 'D_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'config';
$job->provider = 'fake';
@@ -169,7 +169,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'E_unit_' . random_int(1, 10000);
$job->key = 'E_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -199,7 +199,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'f_unit_' . random_int(1, 10000);
$job->key = 'f_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'config';
$job->provider = 'fake';
@@ -230,7 +230,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'g_unit_' . random_int(1, 10000);
$job->key = 'g_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -257,7 +257,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'h_unit_' . random_int(1, 10000);
$job->key = 'h_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -292,7 +292,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'i_unit_' . random_int(1, 10000);
$job->key = 'i_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -327,7 +327,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'j_unit_' . random_int(1, 10000);
$job->key = 'j_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -362,7 +362,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'k_unit_' . random_int(1, 10000);
$job->key = 'k_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -397,7 +397,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'l_unit_' . random_int(1, 10000);
$job->key = 'l_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -432,7 +432,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'm_unit_' . random_int(1, 10000);
$job->key = 'm_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -467,7 +467,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'n_unit_' . random_int(1, 10000);
$job->key = 'n_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -502,7 +502,7 @@ class FakeJobConfigurationTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'o_unit_' . random_int(1, 10000);
$job->key = 'o_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -540,7 +540,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'p_unit_' . random_int(1, 10000);
$job->key = 'p_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'not_new';
$job->provider = 'fake';
@@ -567,7 +567,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'p_unit_' . random_int(1, 10000);
$job->key = 'p_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -594,7 +594,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'p_unit_' . random_int(1, 10000);
$job->key = 'p_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -621,7 +621,7 @@ class FakeJobConfigurationTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'p_unit_' . random_int(1, 10000);
$job->key = 'p_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';

View File

@@ -63,7 +63,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'File_A_unit_' . random_int(1, 10000);
$job->key = 'File_A_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';
@@ -88,7 +88,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'File_B_unit_' . random_int(1, 10000);
$job->key = 'File_B_unit_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'ready_to_run';
$job->provider = 'fake';
@@ -113,7 +113,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'I-Cfile_' . random_int(1, 10000);
$job->key = 'I-Cfile_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'map';
$job->provider = 'file';
@@ -150,7 +150,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'G-Dfile_' . random_int(1, 10000);
$job->key = 'G-Dfile_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'configure-upload';
$job->provider = 'file';
@@ -185,7 +185,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'H-Efile_' . random_int(1, 10000);
$job->key = 'H-Efile_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'map';
$job->provider = 'file';
@@ -220,7 +220,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'F-fFile_' . random_int(1, 10000);
$job->key = 'F-fFile_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'file';
@@ -255,7 +255,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'H-fiGle_' . random_int(1, 10000);
$job->key = 'H-fiGle_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'roles';
$job->provider = 'file';
@@ -290,7 +290,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'DfiHle_' . random_int(1, 10000);
$job->key = 'DfiHle_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'configure-upload';
$job->provider = 'file';
@@ -320,7 +320,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'FfilIe_' . random_int(1, 10000);
$job->key = 'FfilIe_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'map';
$job->provider = 'file';
@@ -350,7 +350,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'CfJile_' . random_int(1, 10000);
$job->key = 'CfJile_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'file';
@@ -380,7 +380,7 @@ class FileJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once()->atLeast();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'EfiKle_' . random_int(1, 10000);
$job->key = 'EfiKle_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'roles';
$job->provider = 'file';

View File

@@ -0,0 +1,167 @@
<?php
/**
* FinTSJobConfigurationTest.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Tests\Unit\Import\JobConfiguration;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\JobConfiguration\FinTSJobConfiguration;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\JobConfiguration\FinTS\ChooseAccountHandler;
use FireflyIII\Support\Import\JobConfiguration\FinTS\NewFinTSJobHandler;
use Log;
use Tests\TestCase;
/**
* Class FinTSJobConfigurationTest
*/
class FinTSJobConfigurationTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
* @covers \FireflyIII\Import\JobConfiguration\FinTSJobConfiguration
*/
public function testConfigurationComplete(): void
{
$this->mock(ImportJobRepositoryInterface::class);
$this->mock(NewFinTSJobHandler::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'fints_jc_A' . $this->randomInt();
$job->status = 'new';
$job->stage = 'go-for-import';
$job->provider = 'fints';
$job->file_type = '';
$job->configuration = [];
$job->save();
$config = new FinTSJobConfiguration;
$config->setImportJob($job);
$this->assertTrue($config->configurationComplete());
}
/**
* @covers \FireflyIII\Import\JobConfiguration\FinTSJobConfiguration
*/
public function testConfigureJob(): void
{
$this->mock(ImportJobRepositoryInterface::class);
$handler = $this->mock(NewFinTSJobHandler::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'fints_jc_B' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fints';
$job->file_type = '';
$job->configuration = [];
$job->save();
$handler->shouldReceive('setImportJob')->atLeast()->once();
$handler->shouldReceive('configureJob')->atLeast()->once()->withArgs([[123]]);
$config = new FinTSJobConfiguration;
$config->setImportJob($job);
try {
$config->configureJob([123]);
} catch (FireflyException $e) {
$this->assertFalse(true, $e->getMessage());
}
}
/**
* @covers \FireflyIII\Import\JobConfiguration\FinTSJobConfiguration
*/
public function testGetNextData(): void
{
$this->mock(ImportJobRepositoryInterface::class);
$handler = $this->mock(ChooseAccountHandler::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'fints_jc_C' . $this->randomInt();
$job->status = 'new';
$job->stage = 'choose_account';
$job->provider = 'fints';
$job->file_type = '';
$job->configuration = [];
$job->save();
$handler->shouldReceive('setImportJob')->atLeast()->once();
$handler->shouldReceive('getNextData')->atLeast()->once()->withNoArgs()->andReturn([456]);
$res = [];
$config = new FinTSJobConfiguration;
$config->setImportJob($job);
try {
$res = $config->getNextData();
} catch (FireflyException $e) {
$this->assertFalse(true, $e->getMessage());
}
$this->assertEquals([456], $res);
}
/**
* @covers \FireflyIII\Import\JobConfiguration\FinTSJobConfiguration
*/
public function testGetNextView(): void
{
$this->mock(ImportJobRepositoryInterface::class);
$this->mock(ChooseAccountHandler::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'fints_jc_D' . $this->randomInt();
$job->status = 'new';
$job->stage = 'choose_account';
$job->provider = 'fints';
$job->file_type = '';
$job->configuration = [];
$job->save();
$res = [];
$config = new FinTSJobConfiguration;
$config->setImportJob($job);
try {
$res = $config->getNextView();
} catch (FireflyException $e) {
$this->assertFalse(true, $e->getMessage());
}
$this->assertEquals('import.fints.choose_account', $res);
}
}

View File

@@ -60,7 +60,7 @@ class SpectreJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'spectre_jc_A' . random_int(1, 10000);
$job->key = 'spectre_jc_A' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -91,7 +91,7 @@ class SpectreJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'spectre_jc_B' . random_int(1, 10000);
$job->key = 'spectre_jc_B' . $this->randomInt();
$job->status = 'new';
$job->stage = 'do-authenticate';
$job->provider = 'spectre';
@@ -125,7 +125,7 @@ class SpectreJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'spectre_jc_C' . random_int(1, 10000);
$job->key = 'spectre_jc_C' . $this->randomInt();
$job->status = 'new';
$job->stage = 'choose-login';
$job->provider = 'spectre';
@@ -157,7 +157,7 @@ class SpectreJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'spectre_jc_D' . random_int(1, 10000);
$job->key = 'spectre_jc_D' . $this->randomInt();
$job->status = 'new';
$job->stage = 'authenticated';
$job->provider = 'spectre';
@@ -188,7 +188,7 @@ class SpectreJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'spectre_jc_E' . random_int(1, 10000);
$job->key = 'spectre_jc_E' . $this->randomInt();
$job->status = 'new';
$job->stage = 'choose-accounts';
$job->provider = 'spectre';

View File

@@ -89,7 +89,7 @@ class YnabJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_jc_B' . random_int(1, 10000);
$job->key = 'ynab_jc_B' . $this->randomInt();
$job->status = 'new';
$job->stage = 'select_budgets';
$job->provider = 'ynab';
@@ -123,7 +123,7 @@ class YnabJobConfigurationTest extends TestCase
$jobRepos->shouldReceive('setUser')->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_jc_C' . random_int(1, 10000);
$job->key = 'ynab_jc_C' . $this->randomInt();
$job->status = 'new';
$job->stage = 'select_accounts';
$job->provider = 'ynab';