mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Update tests so repositories are not called. Saves on DB calls, speeds up tests.
This commit is contained in:
@@ -26,9 +26,9 @@ namespace Tests\Unit\Import\JobConfiguration;
|
||||
use FireflyIII\Import\JobConfiguration\FakeJobConfiguration;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FakeJobConfigurationTest
|
||||
@@ -52,6 +52,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCC(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'A_unit_' . random_int(1, 10000);
|
||||
@@ -62,6 +65,8 @@ class FakeJobConfigurationTest extends TestCase
|
||||
$job->configuration = [];
|
||||
$job->save();
|
||||
|
||||
|
||||
|
||||
// should be false:
|
||||
$configurator = new FakeJobConfiguration;
|
||||
$configurator->setImportJob($job);
|
||||
@@ -75,6 +80,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCAlbumFalse(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'B_unit_' . random_int(1, 10000);
|
||||
@@ -98,6 +106,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCApplyRules(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'C_unit_' . random_int(1, 10000);
|
||||
@@ -123,6 +134,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCBadAlbum(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'D_unit_' . random_int(1, 10000);
|
||||
@@ -151,6 +165,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCBadInfo(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'E_unit_' . random_int(1, 10000);
|
||||
@@ -178,6 +195,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCGoodAlbum(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'f_unit_' . random_int(1, 10000);
|
||||
@@ -206,6 +226,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCGoodNewInfo(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'g_unit_' . random_int(1, 10000);
|
||||
@@ -513,6 +536,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewAlbum(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||
@@ -537,6 +563,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewArtist(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||
@@ -561,6 +590,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewRules(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||
@@ -585,6 +617,9 @@ class FakeJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewSong(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||
|
@@ -27,6 +27,7 @@ namespace Tests\Unit\Import\JobConfiguration;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
||||
@@ -57,6 +58,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCFalse(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'File_A_unit_' . random_int(1, 10000);
|
||||
@@ -80,6 +83,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testCCTrue(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'File_B_unit_' . random_int(1, 10000);
|
||||
@@ -103,6 +108,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJob(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'I-Cfile_' . random_int(1, 10000);
|
||||
@@ -138,6 +145,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextDataCU(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'G-Dfile_' . random_int(1, 10000);
|
||||
@@ -171,6 +180,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextDataMap(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'H-Efile_' . random_int(1, 10000);
|
||||
@@ -204,6 +215,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextDataNew(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'F-fFile_' . random_int(1, 10000);
|
||||
@@ -237,6 +250,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextDataRoles(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'H-fiGle_' . random_int(1, 10000);
|
||||
@@ -270,6 +285,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewCU(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'DfiHle_' . random_int(1, 10000);
|
||||
@@ -298,6 +315,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewMap(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'FfilIe_' . random_int(1, 10000);
|
||||
@@ -326,6 +345,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewNew(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'CfJile_' . random_int(1, 10000);
|
||||
@@ -354,6 +375,8 @@ class FileJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewRoles(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'EfiKle_' . random_int(1, 10000);
|
||||
|
@@ -26,6 +26,7 @@ namespace Tests\Unit\Import\JobConfiguration;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\JobConfiguration\SpectreJobConfiguration;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccountsHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler;
|
||||
@@ -55,6 +56,8 @@ class SpectreJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testConfigurationComplete(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'spectre_jc_A' . random_int(1, 10000);
|
||||
@@ -84,6 +87,8 @@ class SpectreJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJob(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'spectre_jc_B' . random_int(1, 10000);
|
||||
@@ -116,6 +121,8 @@ class SpectreJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextData(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'spectre_jc_C' . random_int(1, 10000);
|
||||
@@ -146,6 +153,8 @@ class SpectreJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextView(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'spectre_jc_D' . random_int(1, 10000);
|
||||
@@ -175,6 +184,8 @@ class SpectreJobConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testGetNextViewAccount(): void
|
||||
{
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$jobRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'spectre_jc_E' . random_int(1, 10000);
|
||||
|
Reference in New Issue
Block a user