mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 08:00:19 +00:00
Refactor journal repositories.
This commit is contained in:
@@ -28,6 +28,7 @@ use FireflyIII\Factory\TransactionGroupFactory;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -59,12 +60,13 @@ class MigrateToGroupsTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$service = $this->mock(JournalDestroyService::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$cliRepos = $this->mock(JournalCLIRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$journalRepos->shouldReceive('getSplitJournals')
|
||||
$cliRepos->shouldReceive('getSplitJournals')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
$cliRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
@@ -89,6 +91,7 @@ class MigrateToGroupsTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$service = $this->mock(JournalDestroyService::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$cliRepos = $this->mock(JournalCLIRepositoryInterface::class);
|
||||
|
||||
$asset = $this->getRandomAsset();
|
||||
$expense = $this->getRandomExpense();
|
||||
@@ -121,10 +124,10 @@ class MigrateToGroupsTest extends TestCase
|
||||
$array = $journal->toArray();
|
||||
|
||||
// mock calls:
|
||||
$journalRepos->shouldReceive('getSplitJournals')
|
||||
$cliRepos->shouldReceive('getSplitJournals')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
$cliRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
->atLeast()->once()
|
||||
->andReturn([$array]);
|
||||
|
||||
@@ -203,19 +206,21 @@ class MigrateToGroupsTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$service = $this->mock(JournalDestroyService::class);
|
||||
$factory = $this->mock(TransactionGroupFactory::class);
|
||||
$cliRepos = $this->mock(JournalCLIRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$cliRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// mock journal things:
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->atLeast()->once()->andReturn(0);
|
||||
$journalRepos->shouldReceive('getJournalCategoryId')->atLeast()->once()->andReturn(0);
|
||||
$journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Some note.');
|
||||
$journalRepos->shouldReceive('getTags')->atLeast()->once()->andReturn(['A', 'B']);
|
||||
$journalRepos->shouldReceive('getMetaField')->atLeast()
|
||||
$cliRepos->shouldReceive('getJournalBudgetId')->atLeast()->once()->andReturn(0);
|
||||
$cliRepos->shouldReceive('getJournalCategoryId')->atLeast()->once()->andReturn(0);
|
||||
$cliRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Some note.');
|
||||
$cliRepos->shouldReceive('getTags')->atLeast()->once()->andReturn(['A', 'B']);
|
||||
$cliRepos->shouldReceive('getMetaField')->atLeast()
|
||||
->withArgs([Mockery::any(), Mockery::any()])
|
||||
->once()->andReturn(null);
|
||||
$journalRepos->shouldReceive('getMetaDate')->atLeast()
|
||||
$cliRepos->shouldReceive('getMetaDate')->atLeast()
|
||||
->withArgs([Mockery::any(), Mockery::any()])
|
||||
->once()->andReturn(null);
|
||||
|
||||
@@ -225,10 +230,10 @@ class MigrateToGroupsTest extends TestCase
|
||||
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('getSplitJournals')
|
||||
$cliRepos->shouldReceive('getSplitJournals')
|
||||
->atLeast()->once()
|
||||
->andReturn(new Collection([$journal]));
|
||||
$journalRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
$cliRepos->shouldReceive('getJournalsWithoutGroup')
|
||||
->atLeast()->once()
|
||||
->andReturn([]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user