mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 20:34:48 +00:00
Update tests so repositories are not called. Saves on DB calls, speeds up tests.
This commit is contained in:
@@ -35,9 +35,9 @@ use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Csv\Exception;
|
||||
use League\Csv\Reader;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ConfigureMappingHandlerTest
|
||||
@@ -59,6 +59,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testApplySpecifics(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapG' . random_int(1, 10000);
|
||||
@@ -94,6 +96,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJob(): void
|
||||
{
|
||||
|
||||
// create fake input for class method:
|
||||
$input = [
|
||||
'mapping' => [
|
||||
@@ -158,6 +161,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testDoColumnConfig(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapE' . random_int(1, 10000);
|
||||
@@ -221,7 +226,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testDoMapOfColumn(): void
|
||||
{
|
||||
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapC' . random_int(1, 10000);
|
||||
@@ -251,6 +257,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetNextData(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapH' . random_int(1, 10000);
|
||||
@@ -332,6 +339,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetPreProcessorName(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapD' . random_int(1, 10000);
|
||||
@@ -360,6 +369,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetReader(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapF' . random_int(1, 10000);
|
||||
@@ -408,6 +418,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetValuesForMapping(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
// create a reader to use in method.
|
||||
// 5 columns, of which #4 (index 3) is budget-id
|
||||
// 5 columns, of which #5 (index 4) is tags-space
|
||||
@@ -475,7 +487,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testSanitizeColumnName(): void
|
||||
{
|
||||
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapB' . random_int(1, 10000);
|
||||
|
||||
@@ -57,6 +57,9 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConfigurationCompleteBasic(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
|
||||
$config = [
|
||||
'column-count' => 5,
|
||||
'column-roles' => [
|
||||
@@ -77,6 +80,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConfigurationCompleteForeign(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$config = [
|
||||
'column-count' => 5,
|
||||
'column-roles' => [
|
||||
@@ -101,6 +106,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConfigurationCompleteNoAmount(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$config = [
|
||||
'column-count' => 5,
|
||||
'column-roles' => [
|
||||
@@ -125,6 +131,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConfigureJob(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-B' . random_int(1, 10000);
|
||||
@@ -178,7 +185,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetExampleFromLine(): void
|
||||
{
|
||||
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$lines = [
|
||||
['one', 'two', '', 'three'],
|
||||
['four', 'five', '', 'six'],
|
||||
@@ -201,6 +208,11 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetExamplesFromFile(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$importRepos->shouldReceive('setConfiguration')->once()
|
||||
->withAnyArgs();
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
@@ -239,6 +251,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetHeadersHas(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
//$importRepos->shouldReceive('setUser')->once();
|
||||
// create a reader to use in method.
|
||||
// 5 columns, of which #4 (index 3) is budget-id
|
||||
// 5 columns, of which #5 (index 4) is tags-space
|
||||
@@ -260,6 +274,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetHeadersNone(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// create a reader to use in method.
|
||||
// 5 columns, of which #4 (index 3) is budget-id
|
||||
// 5 columns, of which #5 (index 4) is tags-space
|
||||
@@ -278,6 +294,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
public function testGetNextData(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
@@ -348,6 +365,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testGetReader(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
@@ -396,6 +414,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIgnoreUnmappableColumns(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$config = [
|
||||
'column-count' => 5,
|
||||
'column-roles' => [
|
||||
@@ -439,6 +459,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsMappingNecessaryNo(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$config = [
|
||||
'column-do-mapping' => [false, false, false],
|
||||
];
|
||||
@@ -452,6 +474,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsMappingNecessaryYes(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$config = [
|
||||
'column-do-mapping' => [false, true, false, false],
|
||||
];
|
||||
@@ -465,6 +489,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testMakeExamplesUnique(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$lines = [
|
||||
['one', 'two', '', 'three'],
|
||||
['four', 'five', '', 'six'],
|
||||
@@ -491,6 +517,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testProcessSpecifics(): void
|
||||
{
|
||||
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$line = [];
|
||||
$config = [
|
||||
'specifics' => [
|
||||
@@ -512,6 +540,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
*/
|
||||
public function testSaveColumCount(): void
|
||||
{
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-A' . random_int(1, 10000);
|
||||
|
||||
Reference in New Issue
Block a user