Expand test coverage and improve transaction management code.

This commit is contained in:
James Cole
2019-07-01 20:22:35 +02:00
parent 94acb50a6f
commit 5bbe1eab7c
63 changed files with 1251 additions and 812 deletions

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Preferences;
use Tests\TestCase;
/**
@@ -56,12 +57,13 @@ class CreateControllerTest extends TestCase
public function testCreate(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->mockDefaultSession();
$this->mockIntroPreference('shown_demo_rules_create');
$ruleGroupRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
$ruleRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
@@ -80,17 +82,17 @@ class CreateControllerTest extends TestCase
public function testCreateFromBill(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$ruleGroupRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
$ruleRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('rules.create-from-bill', [1, 1]));
@@ -114,17 +116,17 @@ class CreateControllerTest extends TestCase
$this->session(['_old_input' => $old]);
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$this->mockIntroPreference('shown_demo_rules_create');
$ruleGroupRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
$ruleRepos->shouldReceive('count')->atLeast()->once()->andReturn(1);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('rules.create', [1]));
$response->assertStatus(200);
@@ -139,12 +141,13 @@ class CreateControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(RuleRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
Preferences::shouldReceive('mark')->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn(new Rule);
$this->session(['rules.create.uri' => 'http://localhost']);