mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 11:48:53 +00:00
Expand test coverage and improve transaction management code.
This commit is contained in:
@@ -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']);
|
||||
|
Reference in New Issue
Block a user