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

@@ -172,6 +172,8 @@ class ShowControllerTest extends TestCase
$collector = $this->mock(GroupCollectorInterface::class);
$this->mockDefaultSession();
// mock calls
$pref = new Preference;

View File

@@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Import;
use FireflyIII\Import\Prerequisites\BunqPrerequisites;
use FireflyIII\Import\Prerequisites\FakePrerequisites;
use FireflyIII\Import\Prerequisites\FilePrerequisites;
use FireflyIII\Import\Prerequisites\SpectrePrerequisites;
use FireflyIII\Import\Prerequisites\YnabPrerequisites;
use FireflyIII\Models\ImportJob;
@@ -57,10 +56,11 @@ class IndexControllerTest extends TestCase
*/
public function testCreateBadJob(): void
{
$this->mockDefaultSession();
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
@@ -70,14 +70,13 @@ class IndexControllerTest extends TestCase
$importJob->provider = 'fake';
$importJob->key = 'fake_job_1';
$this->mockDefaultSession();
// mock calls:
$ynabPrerequisites->shouldReceive('setUser')->once();
$fakePrerequisites->shouldReceive('setUser')->once();
//$fakePrerequisites->shouldReceive('setUser')->once();
$bunqPrerequisites->shouldReceive('setUser')->once();
$spectrePrerequisites->shouldReceive('setUser')->once();
$fakePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
//$fakePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
@@ -94,13 +93,11 @@ class IndexControllerTest extends TestCase
*/
public function testCreateDemoUser(): void
{
Log::debug(sprintf('Now in test %s', __METHOD__));
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
// fake job:
$importJob = new ImportJob;
@@ -110,21 +107,14 @@ class IndexControllerTest extends TestCase
$this->mockDefaultSession();
// mock calls:
$ynabPrerequisites->shouldReceive('setUser')->times(2);
$fakePrerequisites->shouldReceive('setUser')->times(2);
$bunqPrerequisites->shouldReceive('setUser')->times(2);
$spectrePrerequisites->shouldReceive('setUser')->times(2);
$fakePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$fakePrerequisites->shouldReceive('setUser')->atLeast()->once();
$fakePrerequisites->shouldReceive('isComplete')->atLeast()->once()->andReturn(true);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true)->times(3);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$response = $this->get(route('import.create', ['spectre']));
$response->assertStatus(302);
$response->assertRedirect(route('import.index'));
$response->assertStatus(404);
}
/**
@@ -136,10 +126,6 @@ class IndexControllerTest extends TestCase
$repository = $this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
// fake job:
$importJob = new ImportJob;
@@ -151,16 +137,6 @@ class IndexControllerTest extends TestCase
// mock calls
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true)->times(3);
$bunqPrerequisites->shouldReceive('setUser')->times(2);
$bunqPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(false);
$spectrePrerequisites->shouldReceive('setUser')->times(2);
$spectrePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(false);
$ynabPrerequisites->shouldReceive('setUser')->times(2);
$ynabPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(false);
$repository->shouldReceive('create')->withArgs(['fake'])->andReturn($importJob);
$fakePrerequisites->shouldReceive('isComplete')->times(3)->andReturn(false);
@@ -183,10 +159,6 @@ class IndexControllerTest extends TestCase
$repository = $this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
// fake job:
$importJob = new ImportJob;
@@ -201,14 +173,6 @@ class IndexControllerTest extends TestCase
$fakePrerequisites->shouldReceive('isComplete')->times(3)->andReturn(true);
$fakePrerequisites->shouldReceive('setUser')->times(3);
$bunqPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$bunqPrerequisites->shouldReceive('setUser')->times(2);
$spectrePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$spectrePrerequisites->shouldReceive('setUser')->times(2);
$ynabPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$ynabPrerequisites->shouldReceive('setUser')->times(2);
$repository->shouldReceive('create')->withArgs(['fake'])->andReturn($importJob);
@@ -231,10 +195,8 @@ class IndexControllerTest extends TestCase
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
// fake job:
@@ -246,12 +208,12 @@ class IndexControllerTest extends TestCase
$this->mockDefaultSession();
// mock calls
$fakePrerequisites->shouldReceive('setUser')->times(2);
//$fakePrerequisites->shouldReceive('setUser')->times(2);
$bunqPrerequisites->shouldReceive('setUser')->times(2);
$spectrePrerequisites->shouldReceive('setUser')->times(2);
$ynabPrerequisites->shouldReceive('setUser')->times(2);
$fakePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
//$fakePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->times(2)->andReturn(true);
@@ -276,10 +238,8 @@ class IndexControllerTest extends TestCase
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$this->mockDefaultSession();
@@ -303,13 +263,13 @@ class IndexControllerTest extends TestCase
$repository->shouldReceive('getConfiguration')->andReturn($fakeConfig)->once();
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
$fakePrerequisites->shouldReceive('setUser')->times(1);
//$fakePrerequisites->shouldReceive('setUser')->times(1);
$bunqPrerequisites->shouldReceive('setUser')->times(1);
$spectrePrerequisites->shouldReceive('setUser')->times(1);
$ynabPrerequisites->shouldReceive('setUser')->times(1);
//$filePrerequisites->shouldReceive('setUser')->times(1);
$fakePrerequisites->shouldReceive('isComplete')->times(1)->andReturn(true);
//$fakePrerequisites->shouldReceive('isComplete')->times(1)->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->times(1)->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->times(1)->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->times(1)->andReturn(true);
@@ -330,12 +290,10 @@ class IndexControllerTest extends TestCase
// fake stuff:
$userRepository = $this->mock(UserRepositoryInterface::class);
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
$this->mockDefaultSession();
@@ -343,12 +301,12 @@ class IndexControllerTest extends TestCase
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(false);
$fakePrerequisites->shouldReceive('setUser')->once();
//$fakePrerequisites->shouldReceive('setUser')->once();
$bunqPrerequisites->shouldReceive('setUser')->once();
$spectrePrerequisites->shouldReceive('setUser')->once();
$ynabPrerequisites->shouldReceive('setUser')->once();
$fakePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
//$fakePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
@@ -367,26 +325,14 @@ class IndexControllerTest extends TestCase
// fake stuff:
$fakePrerequisites = $this->mock(FakePrerequisites::class);
$bunqPrerequisites = $this->mock(BunqPrerequisites::class);
$spectrePrerequisites = $this->mock(SpectrePrerequisites::class);
$filePrerequisites = $this->mock(FilePrerequisites::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
$ynabPrerequisites = $this->mock(YnabPrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
$this->mockDefaultSession();
// call methods:
$fakePrerequisites->shouldReceive('setUser')->once();
$bunqPrerequisites->shouldReceive('setUser')->once();
$spectrePrerequisites->shouldReceive('setUser')->once();
$ynabPrerequisites->shouldReceive('setUser')->once();
$fakePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$bunqPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$spectrePrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$ynabPrerequisites->shouldReceive('isComplete')->once()->andReturn(true);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true);
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(false);

View File

@@ -115,7 +115,7 @@ class JobStatusControllerTest extends TestCase
{
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$tag = $this->user()->tags()->first();
$tag = $this->getRandomTag();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'Cfake_job_' . $this->randomInt();
@@ -127,7 +127,6 @@ class JobStatusControllerTest extends TestCase
$job->save();
$this->mockDefaultSession();
$importRepos->shouldReceive('countTransactions')->once()->andReturn(0);
// call thing.

View File

@@ -22,7 +22,10 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Import;
use FireflyIII\Import\Prerequisites\BunqPrerequisites;
use FireflyIII\Import\Prerequisites\FakePrerequisites;
use FireflyIII\Import\Prerequisites\SpectrePrerequisites;
use FireflyIII\Import\Prerequisites\YnabPrerequisites;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -57,9 +60,13 @@ class PrerequisitesControllerTest extends TestCase
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$prereq = $this->mock(BunqPrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
// mock some prerequisites:
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'A_pre_job_' . $this->randomInt();
@@ -69,23 +76,25 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$prereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$prereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$spectrePrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$ynabPrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$prereq->shouldReceive('setUser')->times(2);
$prereq->shouldReceive('isComplete')->times(2)->andReturn(false);
$prereq->shouldReceive('getView')->once()->andReturn('import.fake.prerequisites');
$prereq->shouldReceive('getViewParameters')->once()->andReturn(['api_key' => '']);
$this->be($this->user());
$response = $this->get(route('import.prerequisites.index', ['fake', $job->key]));
$response = $this->get(route('import.prerequisites.index', ['bunq', $job->key]));
$response->assertStatus(200);
}
@@ -99,6 +108,10 @@ class PrerequisitesControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -109,16 +122,20 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'fake_api_key', null])->andReturnNull();
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$spectrePrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$ynabPrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$this->be($this->user());
$response = $this->get(route('import.prerequisites.index', ['fake', $job->key]));
$response = $this->get(route('import.prerequisites.index', ['bunq', $job->key]));
$response->assertStatus(302);
$response->assertRedirect(route('import.index'));
}
@@ -130,29 +147,39 @@ class PrerequisitesControllerTest extends TestCase
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->andReturn(true)->atLeast()->once();
$spectrePrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
$ynabPrereq->shouldReceive('isComplete')->andReturn(false)->atLeast()->once();
//Preferences::shouldReceive('setForUser')->withArgs([Mockery::any(),'x','x'])->atLeast()->once();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'C_pre_job_' . $this->randomInt();
$job->status = 'new';
$job->provider = 'fake';
$job->provider = 'bunq';
$job->transactions = [];
$job->file_type = '';
$job->save();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
$prereq->shouldReceive('setUser')->times(2);
$prereq->shouldReceive('isComplete')->times(2)->andReturn(true);
$this->be($this->user());
$response = $this->get(route('import.prerequisites.index', ['fake', $job->key]));
$response = $this->get(route('import.prerequisites.index', ['bunq', $job->key]));
$response->assertStatus(302);
$response->assertRedirect(route('import.job.configuration.index', [$job->key]));
@@ -167,13 +194,23 @@ class PrerequisitesControllerTest extends TestCase
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$spectrePrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$ynabPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$bunqPrereq->shouldReceive('storePrerequisites')->atLeast()->once()->andReturn(new MessageBag);
$job = new ImportJob;
@@ -186,13 +223,13 @@ class PrerequisitesControllerTest extends TestCase
$job->save();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$prereq->shouldReceive('setUser')->times(2);
$prereq->shouldReceive('storePrerequisites')->once()->andReturn(new MessageBag);
//$prereq->shouldReceive('setUser')->times(2);
//$prereq->shouldReceive('storePrerequisites')->once()->andReturn(new MessageBag);
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
$this->be($this->user());
$response = $this->post(route('import.prerequisites.post', ['fake', $job->key]));
$response = $this->post(route('import.prerequisites.post', ['bunq', $job->key]));
$response->assertStatus(302);
$response->assertRedirect(route('import.job.configuration.index', [$job->key]));
}
@@ -205,29 +242,41 @@ class PrerequisitesControllerTest extends TestCase
public function testPostBadState(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
$job = new ImportJob;
$job->user_id = $this->user()->id;
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$spectrePrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$ynabPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'D_pre_job_' . $this->randomInt();
$job->status = 'badstate';
$job->provider = 'fake';
$job->provider = 'bunq';
$job->transactions = [];
$job->file_type = '';
$job->save();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$prereq->shouldReceive('setUser')->times(1);
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
$this->be($this->user());
$response = $this->post(route('import.prerequisites.post', ['fake', $job->key]));
$response = $this->post(route('import.prerequisites.post', ['bunq', $job->key]));
$response->assertStatus(302);
$response->assertRedirect(route('import.index'));
$response->assertSessionHas('error', 'To access this page, your import job cannot have status "badstate".');
@@ -242,23 +291,28 @@ class PrerequisitesControllerTest extends TestCase
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$spectrePrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$ynabPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$bunqPrereq->shouldReceive('storePrerequisites')->atLeast()->once()->andReturn(new MessageBag);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$prereq->shouldReceive('setUser')->once();
$prereq->shouldReceive('storePrerequisites')->once()->andReturn(new MessageBag);
$prereq->shouldReceive('setUser')->times(1);
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
$this->be($this->user());
$response = $this->post(route('import.prerequisites.post', ['fake']));
$response = $this->post(route('import.prerequisites.post', ['bunq']));
$response->assertStatus(302);
$response->assertRedirect(route('import.index'));
}
@@ -275,16 +329,11 @@ class PrerequisitesControllerTest extends TestCase
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'D_pre_job_' . $this->randomInt();
$job->status = 'new';
$job->provider = 'fake';
$job->provider = 'bunq';
$job->transactions = [];
$job->file_type = '';
$job->save();
@@ -293,16 +342,30 @@ class PrerequisitesControllerTest extends TestCase
$messages->add('some', 'message');
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$prereq->shouldReceive('setUser')->times(1);
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
$prereq->shouldReceive('setUser')->once();
$prereq->shouldReceive('storePrerequisites')->once()->andReturn($messages);
// mock some prerequisites:
$bunqPrereq = $this->mock(BunqPrerequisites::class);
$spectrePrereq = $this->mock(SpectrePrerequisites::class);
$ynabPrereq = $this->mock(YnabPrerequisites::class);
// fake calls to prereq classes
$bunqPrereq->shouldReceive('setUser')->atLeast()->once();
$spectrePrereq->shouldReceive('setUser')->atLeast()->once();
$ynabPrereq->shouldReceive('setUser')->atLeast()->once();
$bunqPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$spectrePrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$ynabPrereq->shouldReceive('isComplete')->atLeast()->once()->andReturn(false);
$bunqPrereq->shouldReceive('storePrerequisites')->atLeast()->once()->andReturn($messages);
$this->be($this->user());
$response = $this->post(route('import.prerequisites.post', ['fake', $job->key]));
$response = $this->post(route('import.prerequisites.post', ['bunq', $job->key]));
$response->assertStatus(302);
$response->assertRedirect(route('import.prerequisites.index', ['fake', $job->key]));
$response->assertRedirect(route('import.prerequisites.index', ['bunq', $job->key]));
$response->assertSessionHas('error', 'message');
}
}

View File

@@ -252,6 +252,43 @@ class BoxControllerTest extends TestCase
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Json\BoxController
*/
public function testNetWorthPast(): void
{
$this->mockDefaultSession();
$result = [
[
'currency' => TransactionCurrency::find(1),
'balance' => '3',
],
];
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
Amount::shouldReceive('formatAnything')->andReturn('-100');
$netWorthHelper = $this->mock(NetWorthInterface::class);
$netWorthHelper->shouldReceive('setUser')->once();
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1');
$start = new Carbon;
$start->subMonths(6)->startOfMonth();
$end = clone $start;
$end->endOfMonth();
$this->session(['start' => $start, 'end' => $end]);
$this->be($this->user());
$response = $this->get(route('json.box.net-worth'));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Json\BoxController
*/

View File

@@ -25,7 +25,6 @@ namespace Tests\Feature\Controllers\Popup;
use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\PopupReportInterface;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@@ -76,6 +75,8 @@ class ReportControllerTest extends TestCase
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertSee('Firefly III cannot handle');
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -103,6 +104,7 @@ class ReportControllerTest extends TestCase
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertSee('Firefly III cannot handle');
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -110,18 +112,17 @@ class ReportControllerTest extends TestCase
*/
public function testBalanceAmountDefaultNoBudget(): void
{
$this->mockDefaultSession();
$this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$account = $this->getRandomAsset();
$this->mockDefaultSession();
$popupHelper->shouldReceive('balanceForNoBudget')->andReturn([]);
$budgetRepos->shouldReceive('findNull')->andReturn(new Budget)->once()->withArgs([0]);
$budgetRepos->shouldReceive('findNull')->andReturn(null)->once()->withArgs([0]);
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
//$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
Amount::shouldReceive('formatAnything')->andReturn('-100');
@@ -142,6 +143,7 @@ class ReportControllerTest extends TestCase
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertSee($account->name);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -157,6 +159,7 @@ class ReportControllerTest extends TestCase
$budget = $this->getRandomBudget();
$this->mockDefaultSession();
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
@@ -178,6 +181,7 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -213,6 +217,7 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -220,8 +225,8 @@ class ReportControllerTest extends TestCase
*/
public function testBudgetSpentAmount(): void
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$budget = $this->getRandomBudget();
@@ -230,6 +235,42 @@ class ReportControllerTest extends TestCase
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
$popupHelper->shouldReceive('byBudget')->andReturn([]);
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$this->be($this->user());
$arguments = [
'attributes' => [
'location' => 'budget-spent-amount',
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
'accounts' => 1,
'accountId' => 1,
'categoryId' => 1,
'budgetId' => 1,
],
];
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
*/
public function testBudgetSpentAmountNoBudget(): void
{
$this->mock(AccountRepositoryInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$this->mockDefaultSession();
$budgetRepos->shouldReceive('findNull')->andReturnNull()->once()->withArgs([1]);
$popupHelper->shouldReceive('byBudget')->andReturn([]);
$this->be($this->user());
$arguments = [
'attributes' => [
@@ -245,6 +286,7 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -261,6 +303,40 @@ class ReportControllerTest extends TestCase
$this->mockDefaultSession();
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
$popupHelper->shouldReceive('byCategory')->andReturn([]);
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$this->be($this->user());
$arguments = [
'attributes' => [
'location' => 'category-entry',
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
'accounts' => 1,
'accountId' => 1,
'categoryId' => 1,
'budgetId' => 1,
],
];
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
*/
public function testCategoryEntryUnknown(): void
{
$this->mock(BudgetRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$this->mockDefaultSession();
$categoryRepos->shouldReceive('findNull')->andReturn(null)->once()->withArgs([1]);
$popupHelper->shouldReceive('byCategory')->andReturn([]);
$this->be($this->user());
$arguments = [
@@ -277,6 +353,8 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
$response->assertSee('This is an unknown category. Apologies.');
}
/**
@@ -291,6 +369,8 @@ class ReportControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = $this->getRandomAsset();
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
$popupHelper->shouldReceive('byExpenses')->andReturn([]);
@@ -310,6 +390,42 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
*/
public function testExpenseEntryUnknown(): void
{
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
$popupHelper->shouldReceive('byExpenses')->andReturn([]);
$this->be($this->user());
$arguments = [
'attributes' => [
'location' => 'expense-entry',
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
'accounts' => 1,
'accountId' => 1,
'categoryId' => 1,
'budgetId' => 1,
],
];
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
$response->assertSee('This is an unknown account. Apologies.');
}
/**
@@ -327,6 +443,7 @@ class ReportControllerTest extends TestCase
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
$popupHelper->shouldReceive('byIncome')->andReturn([]);
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
$this->be($this->user());
$arguments = [
@@ -343,6 +460,41 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
*/
public function testIncomeEntryUnknown(): void
{
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
$popupHelper->shouldReceive('byIncome')->andReturn([]);
$this->be($this->user());
$arguments = [
'attributes' => [
'location' => 'income-entry',
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
'accounts' => 1,
'accountId' => 1,
'categoryId' => 1,
'budgetId' => 1,
],
];
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
/**
@@ -369,5 +521,6 @@ class ReportControllerTest extends TestCase
$uri = route('popup.general') . '?' . http_build_query($arguments);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
}
}

View File

@@ -166,6 +166,127 @@ class CreateControllerTest extends TestCase
$response->assertSessionHas('success');
}
/**
* Stores a withdrawal, but destination is invalid
*
* @covers \FireflyIII\Http\Controllers\Recurring\CreateController
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
*/
public function testStoreWithdrawalInvalidDest(): void
{
// mock repositories, even if not used.
$this->mock(BudgetRepositoryInterface::class);
$this->mock(RecurringRepositoryInterface::class);
$validator = $this->mock(AccountValidator::class);
$source = $this->getRandomAsset();
$destination = $this->getRandomExpense();
$tomorrow = Carbon::now()->addDays(2);
$this->mockDefaultSession();
// validator:
$validator->shouldReceive('setTransactionType')->withArgs(['withdrawal'])->atLeast()->once();
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(false);
$data = [
'title' => sprintf('hello %d', $this->randomInt()),
'first_date' => $tomorrow->format('Y-m-d'),
'repetition_type' => 'daily',
'skip' => 0,
'recurring_description' => sprintf('Some descr %d', $this->randomInt()),
'active' => '1',
'apply_rules' => '1',
'foreign_amount' => '1',
'foreign_currency_id' => '2',
// mandatory for transaction:
'transaction_description' => 'Some descr',
'transaction_type' => 'withdrawal',
'transaction_currency_id' => '1',
'amount' => '30',
// mandatory account info:
'source_id' => $source->id,
'withdrawal_destination_id' => $destination->id,
// optional fields:
'budget_id' => '1',
'category' => 'CategoryA',
'tags' => 'A,B,C',
'create_another' => '1',
'repetition_end' => 'times',
'repetitions' => 3,
];
$this->be($this->user());
$response = $this->post(route('recurring.store'), $data);
$response->assertStatus(302);
$response->assertSessionHas('errors');
}
/**
* Try to store withdrawal, but the source account is invalid.
*
* @covers \FireflyIII\Http\Controllers\Recurring\CreateController
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
*/
public function testStoreWithdrawalInvalidSource(): void
{
$this->mockDefaultSession();
// mock repositories, even if not used.
$this->mock(BudgetRepositoryInterface::class);
$this->mock(RecurringRepositoryInterface::class);
$validator = $this->mock(AccountValidator::class);
$source = $this->getRandomAsset();
$destination = $this->getRandomExpense();
$tomorrow = Carbon::now()->addDays(2);
// validator:
$validator->shouldReceive('setTransactionType')->withArgs(['withdrawal'])->atLeast()->once();
// source account is invalid.
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(false);
$data = [
'title' => sprintf('hello %d', $this->randomInt()),
'first_date' => $tomorrow->format('Y-m-d'),
'repetition_type' => 'daily',
'skip' => 0,
'recurring_description' => sprintf('Some descr %d', $this->randomInt()),
'active' => '1',
'apply_rules' => '1',
'foreign_amount' => '1',
'foreign_currency_id' => '2',
// mandatory for transaction:
'transaction_description' => 'Some descr',
'transaction_type' => 'withdrawal',
'transaction_currency_id' => '1',
'amount' => '30',
// mandatory account info:
'source_id' => $source->id,
'withdrawal_destination_id' => $destination->id,
// optional fields:
'budget_id' => '1',
'category' => 'CategoryA',
'tags' => 'A,B,C',
'create_another' => '1',
'repetition_end' => 'times',
'repetitions' => 3,
];
$this->be($this->user());
$response = $this->post(route('recurring.store'), $data);
$response->assertStatus(302);
$response->assertSessionHas('errors');
}
/**
* Stores a withdrawal. But throw error.
*

View File

@@ -103,6 +103,62 @@ class IndexControllerTest extends TestCase
$response->assertSee('<ol class="breadcrumb">');
}
/**
* The last time the recurring job fired it was a long time ago.
*
* @covers \FireflyIII\Http\Controllers\Recurring\IndexController
*/
public function testIndexLongAgo(): void
{
$repository = $this->mock(RecurringRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$categoryFactory = $this->mock(CategoryFactory::class);
$transformer = $this->mock(RecurrenceTransformer::class);
// mock calls
$pref = new Preference;
$pref->data = 50;
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
$this->mockDefaultSession();
$transformer->shouldReceive('setParameters')->atLeast()->once();
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
[
'id' => 5,
'first_date' => '2018-01-01',
'repeat_until' => null,
'latest_date' => null,
]
);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$config = new Configuration;
$config->data = 1;
$falseConfig = new Configuration;
$falseConfig->data = false;
$collection = $this->user()->recurrences()->take(2)->get();
// mock cron job config:
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
$repository->shouldReceive('get')->andReturn($collection)->once();
$this->be($this->user());
$response = $this->get(route('recurring.index'));
$response->assertStatus(200);
$response->assertSee('<ol class="breadcrumb">');
$response->assertSessionHas('warning');
}
/**
* @covers \FireflyIII\Http\Controllers\Recurring\IndexController
*/

View File

@@ -139,8 +139,8 @@ class CreateControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(RuleRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(RuleGroupRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -155,7 +155,7 @@ class CreateControllerTest extends TestCase
'title' => 'A',
'trigger' => 'store-journal',
'description' => 'D',
'rule_triggers' => [
'triggers' => [
[
'type' => 'description_is',
'value' => 'A',
@@ -163,7 +163,7 @@ class CreateControllerTest extends TestCase
],
],
'rule_actions' => [
'actions' => [
[
'type' => 'set_category',
'value' => 'C',

View File

@@ -78,6 +78,7 @@ class CreateControllerTest extends TestCase
$repository->shouldReceive('find')->andReturn(new RuleGroup);
$data = [
'title' => 'A',
'active' => '1',
'description' => 'No description',
];

View File

@@ -58,7 +58,11 @@ class IndexControllerTest extends TestCase
$collector = $this->mock(GroupCollectorInterface::class);
// generic set for the info blocks:
$groupArray = [$this->getRandomWithdrawalAsArray()];
$groupArray = [
$this->getRandomWithdrawalAsArray(),
$this->getRandomDepositAsArray(),
$this->getRandomTransferAsArray(),
];
// role?
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
@@ -88,6 +92,96 @@ class IndexControllerTest extends TestCase
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\IndexController
*/
public function testIndexDeposit(): void
{
$this->mockDefaultSession();
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
// generic set for the info blocks:
$groupArray = [
$this->getRandomWithdrawalAsArray(),
$this->getRandomDepositAsArray(),
$this->getRandomTransferAsArray(),
];
// role?
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
// make paginator.
$paginator = new LengthAwarePaginator([$group], 1, 40, 1);
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('10');
$collector->shouldReceive('setTypes')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setLimit')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setPage')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withAccountInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('getPaginatedGroups')->atLeast()->once()->andReturn($paginator);
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn($groupArray);
$pref = new Preference;
$pref->data = 50;
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
$this->be($this->user());
$response = $this->get(route('transactions.index', ['deposit']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\IndexController
*/
public function testIndexTransfers(): void
{
$this->mockDefaultSession();
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
// generic set for the info blocks:
$groupArray = [
$this->getRandomWithdrawalAsArray(),
$this->getRandomDepositAsArray(),
$this->getRandomTransferAsArray(),
];
// role?
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
// make paginator.
$paginator = new LengthAwarePaginator([$group], 1, 40, 1);
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('10');
$collector->shouldReceive('setTypes')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setLimit')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setPage')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withAccountInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('getPaginatedGroups')->atLeast()->once()->andReturn($paginator);
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn($groupArray);
$pref = new Preference;
$pref->data = 50;
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
$this->be($this->user());
$response = $this->get(route('transactions.index', ['transfers']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\IndexController

View File

@@ -286,6 +286,47 @@ abstract class TestCase extends BaseTestCase
];
}
/**
* @return array
*/
public function getRandomTransferAsArray(): array
{
$transfer = $this->getRandomTransfer();
$euro = $this->getEuro();
$category = $this->getRandomCategory();
$source = $this->getRandomAsset();
$dest = $this->getRandomAsset($source->id);
try {
$date = new Carbon;
} catch (Exception $e) {
$e->getMessage();
}
return [
'transaction_group_id' => $transfer->transaction_group_id,
'transaction_journal_id' => $transfer->id,
'transaction_type_type' => 'Transfer',
'currency_id' => $euro->id,
'foreign_currency_id' => null,
'date' => $date,
'description' => sprintf('I am descr #%d', $this->randomInt()),
'source_account_id' => $source->id,
'source_account_name' => $source->name,
'foreign_amount' => null,
'destination_account_id' => $dest->id,
'destination_account_name' => $dest->name,
'currency_name' => $euro->name,
'currency_code' => $euro->code,
'currency_symbol' => $euro->symbol,
'currency_decimal_places' => $euro->decimal_places,
'amount' => '-30',
'category_id' => $category->id,
'category_name' => $category->name,
];
}
/**
* @return array
* @throws Exception
@@ -416,9 +457,7 @@ abstract class TestCase extends BaseTestCase
*/
public function demoUser(): User
{
throw new FireflyException('demoUser()-method is obsolete.');
return User::find(4);
return User::where('email', 'demo@firefly')->first();
}
/**
@@ -558,6 +597,14 @@ abstract class TestCase extends BaseTestCase
return $this->getRandomGroup(TransactionType::WITHDRAWAL);
}
/**
* @return TransactionGroup
*/
protected function getRandomTransferGroup(): TransactionGroup
{
return $this->getRandomGroup(TransactionType::TRANSFER);
}
/**
* @return TransactionGroup
*/

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';

View File

@@ -56,7 +56,7 @@ class BunqRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'brY_' . random_int(1, 10000);
$job->key = 'brY_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'bunq';
@@ -96,7 +96,7 @@ class BunqRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'brY_' . random_int(1, 10000);
$job->key = 'brY_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'bunq';
@@ -140,7 +140,7 @@ class BunqRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'brX_' . random_int(1, 10000);
$job->key = 'brX_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'new';
$job->provider = 'bunq';

View File

@@ -55,7 +55,7 @@ class FakeRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'a_route_' . random_int(1, 10000);
$job->key = 'a_route_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'ahoy';
$job->provider = 'fake';
@@ -91,7 +91,7 @@ class FakeRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'a_route_' . random_int(1, 10000);
$job->key = 'a_route_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'final';
$job->provider = 'fake';
@@ -128,7 +128,7 @@ class FakeRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'a_route_' . random_int(1, 10000);
$job->key = 'a_route_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'new';
$job->provider = 'fake';

View File

@@ -25,9 +25,11 @@ namespace Tests\Unit\Import\Routine;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Routine\BunqRoutine;
use FireflyIII\Import\Routine\FileRoutine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\Routine\Bunq\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\File\CSVProcessor;
use Log;
use Mockery;
@@ -55,35 +57,35 @@ class FileRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'a_fr_' . random_int(1, 10000);
$job->key = 'brY_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'ready_to_run';
$job->provider = 'file';
$job->stage = 'go-for-import';
$job->provider = 'bunq';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock
$processor = $this->mock(CSVProcessor::class);
// mock stuff:
$repository = $this->mock(ImportJobRepositoryInterface::class);
$handler = $this->mock(StageImportDataHandler::class);
// calls
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'provider_finished'])->once();
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), ['a' => 'b']])->once();
$repository->shouldReceive('getConfiguration')->withArgs([Mockery::any()])->once()->andReturn([]);
$processor->shouldReceive('setImportJob')->once();
$processor->shouldReceive('run')->once()->andReturn(['a' => 'b']);
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running']);
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'provider_finished']);
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final']);
$repository->shouldReceive('appendTransactions')->withArgs([Mockery::any(), ['a' => 'c']])->once();
$routine = new FileRoutine;
$handler->shouldReceive('setImportJob')->once();
$handler->shouldReceive('run')->once();
$handler->shouldReceive('getTransactions')->once()->andReturn(['a' => 'c']);
$handler->shouldReceive('isStillRunning')->andReturn(false);
$routine = new BunqRoutine;
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
$this->assertFalse(true, $e->getMessage());
}
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* FinTSRoutineTest.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\Routine;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Routine\FinTSRoutine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\Routine\FinTS\StageImportDataHandler;
use Log;
use Mockery;
use Tests\TestCase;
/**
* Class FinTSRoutineTest
*/
class FinTSRoutineTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
* @covers \FireflyIII\Import\Routine\FinTSRoutine
*/
public function testRunDefault(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'a_fin_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'fints';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock
$handler = $this->mock(StageImportDataHandler::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
// calls
$repository->shouldReceive('setUser')->atLeast()->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'provider_finished'])->once();
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final'])->once();
$repository->shouldReceive('setTransactions')->withArgs([Mockery::any(), ['a' => 'b']])->once();
$handler->shouldReceive('setImportJob')->atLeast()->once();
$handler->shouldReceive('run')->once()->atLeast()->once();
$handler->shouldReceive('getTransactions')->atLeast()->once()->andReturn(['a' => 'b']);
$routine = new FinTSRoutine;
$routine->setImportJob($job);
try {
$routine->run();
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
}

View File

@@ -57,7 +57,7 @@ class SpectreRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR2b' . random_int(1, 10000);
$job->key = 'SR2b' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'authenticated';
$job->provider = 'spectre';
@@ -95,7 +95,7 @@ class SpectreRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR1A' . random_int(1, 10000);
$job->key = 'SR1A' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'do-authenticate';
$job->provider = 'spectre';
@@ -126,7 +126,7 @@ class SpectreRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR3c' . random_int(1, 10000);
$job->key = 'SR3c' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'spectre';
@@ -165,7 +165,7 @@ class SpectreRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR4A' . random_int(1, 10000);
$job->key = 'SR4A' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -205,7 +205,7 @@ class SpectreRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'SR5A' . random_int(1, 10000);
$job->key = 'SR5A' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'new';
$job->provider = 'spectre';

View File

@@ -57,7 +57,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_7_' . random_int(1, 10000);
$job->key = 'ynab_r_7_' . $this->randomInt();
$job->status = 'not_ready_to_run';
$job->stage = 'bad_state';
$job->provider = 'ynab';
@@ -88,7 +88,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_6_' . random_int(1, 10000);
$job->key = 'ynab_r_6_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'bad_state';
$job->provider = 'ynab';
@@ -119,7 +119,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_1_' . random_int(1, 10000);
$job->key = 'ynab_r_1_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'get_access_token';
$job->provider = 'ynab';
@@ -158,7 +158,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_4_' . random_int(1, 10000);
$job->key = 'ynab_r_4_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'get_accounts';
$job->provider = 'ynab';
@@ -198,7 +198,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_5_' . random_int(1, 10000);
$job->key = 'ynab_r_5_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'go-for-import';
$job->provider = 'ynab';
@@ -239,7 +239,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_2_' . random_int(1, 10000);
$job->key = 'ynab_r_2_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'get_budgets';
$job->provider = 'ynab';
@@ -281,7 +281,7 @@ class YnabRoutineTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'ynab_r_3_' . random_int(1, 10000);
$job->key = 'ynab_r_3_' . $this->randomInt();
$job->status = 'ready_to_run';
$job->stage = 'get_budgets';
$job->provider = 'ynab';

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@ class IsDemoUserTest extends TestCase
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
Route::middleware([StartFireflySession::class, IsDemoUser::class])->any(
'/_test/is-demo', function () {
'/_test/is-demo', static function () {
return 'OK';
}
);
@@ -68,6 +68,7 @@ class IsDemoUserTest extends TestCase
$response = $this->get('/_test/is-demo');
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
$response->assertSessionHas('info');
}
/**

View File

@@ -42,7 +42,7 @@ class IsSandstormUserTest extends TestCase
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
Route::middleware(IsSandStormUser::class)->any(
'/_test/is-sandstorm', function () {
'/_test/is-sandstorm',static function () {
return 'OK';
}
);

View File

@@ -71,4 +71,18 @@ class SandstormTest extends TestCase
putenv('SANDSTORM=0');
}
/**
* @covers \FireflyIII\Http\Middleware\Sandstorm
*/
public function testMiddlewareNotSandstorm(): void
{
putenv('SANDSTORM=0');
$response = $this->get('/_test/sandstorm');
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
$response->assertSee('sandstorm-anon: false');
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* SecureHeadersTest.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/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Middleware;
use Config;
use FireflyIII\Http\Middleware\SecureHeaders;
use Log;
use Route;
use Symfony\Component\HttpFoundation\Response;
use Tests\TestCase;
/**
* Class SecureHeadersTest
*/
class SecureHeadersTest extends TestCase
{
/**
* Set up test
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
Route::middleware(SecureHeaders::class)->any(
'/_test/secureheaders', static function () {
return view('test.test');
}
);
}
/**
* @covers \FireflyIII\Http\Middleware\SecureHeaders
*/
public function testMiddlewareBasic(): void
{
$response = $this->get('/_test/secureheaders');
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
// verify headers
$response->assertHeader('Content-Security-Policy', "default-src 'none'; object-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' ; style-src 'self' 'unsafe-inline'; base-uri 'self'; font-src 'self' data:; connect-src 'self'; img-src 'self' data: https://api.tiles.mapbox.com ; manifest-src 'self'; form-action 'self'");
$response->assertheader('X-XSS-Protection', '1; mode=block');
$response->assertHeader('X-Frame-Options', 'deny');
$response->assertheader('X-Content-Type-Options', 'nosniff');
$response->assertheader('Referrer-Policy', 'no-referrer');
$response->assertheader('Feature-Policy', "geolocation 'none'; midi 'none'; sync-xhr 'self'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'");
}
/**
* @covers \FireflyIII\Http\Middleware\SecureHeaders
*/
public function testMiddlewareGoogleAnalytics(): void
{
// response changes when config value is different.
Config::set('firefly.analytics_id', 'abc');
$response = $this->get('/_test/secureheaders');
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
// verify headers
$response->assertHeader('Content-Security-Policy', "default-src 'none'; object-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' www.googletagmanager.com/gtag/js https://www.google-analytics.com/analytics.js; style-src 'self' 'unsafe-inline'; base-uri 'self'; font-src 'self' data:; connect-src 'self'; img-src 'self' data: https://api.tiles.mapbox.com https://www.google-analytics.com/; manifest-src 'self'; form-action 'self'");
$response->assertheader('X-XSS-Protection', '1; mode=block');
$response->assertheader('X-Content-Type-Options', 'nosniff');
$response->assertheader('Referrer-Policy', 'no-referrer');
$response->assertHeader('X-Frame-Options', 'deny');
$response->assertheader('Feature-Policy', "geolocation 'none'; midi 'none'; sync-xhr 'self'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'");
}
/**
* @covers \FireflyIII\Http\Middleware\SecureHeaders
*/
public function testMiddlewareFrameHeader(): void
{
// response changes when config value is different.
Config::set('firefly.disable_frame_header', true);
$response = $this->get('/_test/secureheaders');
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
// verify headers
$response->assertHeader('Content-Security-Policy', "default-src 'none'; object-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' ; style-src 'self' 'unsafe-inline'; base-uri 'self'; font-src 'self' data:; connect-src 'self'; img-src 'self' data: https://api.tiles.mapbox.com ; manifest-src 'self'; form-action 'self'");
$response->assertheader('X-XSS-Protection', '1; mode=block');
$response->assertheader('X-Content-Type-Options', 'nosniff');
$response->assertheader('Referrer-Policy', 'no-referrer');
$response->assertHeaderMissing('X-Frame-Options');
$response->assertheader('Feature-Policy', "geolocation 'none'; midi 'none'; sync-xhr 'self'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'");
}
}