Update tests so repositories are not called. Saves on DB calls, speeds up tests.

This commit is contained in:
James Cole
2018-09-04 09:52:19 +02:00
parent 46ba0a5a5a
commit 07edbe758a
111 changed files with 1524 additions and 98 deletions
@@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
@@ -58,6 +59,9 @@ class BulkControllerTest extends TestCase
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
@@ -83,6 +87,9 @@ class BulkControllerTest extends TestCase
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalSourceAccounts')
@@ -119,6 +126,9 @@ class BulkControllerTest extends TestCase
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
@@ -154,6 +164,8 @@ class BulkControllerTest extends TestCase
];
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->times(4)->andReturn(new TransactionJournal);
@@ -192,6 +204,8 @@ class BulkControllerTest extends TestCase
];
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->times(4)->andReturn(new TransactionJournal, null);
@@ -30,9 +30,11 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Log;
use Mockery;
use Tests\TestCase;
/**
@@ -61,6 +63,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
// find deposit:
$deposit = $this->getRandomDeposit();
@@ -93,6 +97,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
// find deposit:
$deposit = $this->getRandomDeposit();
@@ -124,6 +130,8 @@ class ConvertControllerTest extends TestCase
// find deposit:
$deposit = $this->getRandomDeposit();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn($deposit);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
@@ -141,6 +149,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
@@ -173,6 +183,9 @@ class ConvertControllerTest extends TestCase
// find transfer:
$transfer = $this->getRandomTransfer();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn($transfer);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
@@ -193,6 +206,9 @@ class ConvertControllerTest extends TestCase
$transfer = $this->getRandomTransfer();
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
@@ -219,6 +235,9 @@ class ConvertControllerTest extends TestCase
$withdrawal = $this->getRandomWithdrawal();
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
@@ -244,6 +263,9 @@ class ConvertControllerTest extends TestCase
$withdrawal = $this->getRandomWithdrawal();
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
@@ -272,6 +294,7 @@ class ConvertControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -293,6 +316,8 @@ class ConvertControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -315,6 +340,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -333,6 +360,8 @@ class ConvertControllerTest extends TestCase
public function testPostIndexErrored(): void
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$account = $this->user()->accounts()->first();
// find withdrawal:
@@ -365,6 +394,8 @@ class ConvertControllerTest extends TestCase
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -386,6 +417,8 @@ class ConvertControllerTest extends TestCase
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -414,6 +447,8 @@ class ConvertControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -438,6 +473,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -456,6 +493,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -474,6 +513,8 @@ class ConvertControllerTest extends TestCase
{
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -27,7 +27,9 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@@ -53,6 +55,10 @@ class LinkControllerTest extends TestCase
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -67,6 +73,8 @@ class LinkControllerTest extends TestCase
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('destroyLink');
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -89,6 +97,8 @@ class LinkControllerTest extends TestCase
{
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$data = [
'link_other' => 8,
'link_type' => '1_inward',
@@ -115,6 +125,8 @@ class LinkControllerTest extends TestCase
{
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$data = [
'link_other' => 8,
'link_type' => '1_inward',
@@ -144,6 +156,9 @@ class LinkControllerTest extends TestCase
];
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$journalRepos->shouldReceive('findNull')->andReturn(null);
@@ -162,6 +177,8 @@ class LinkControllerTest extends TestCase
{
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$data = [
'link_other' => 8,
'link_type' => '1_inward',
@@ -188,6 +205,8 @@ class LinkControllerTest extends TestCase
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('switchLink')->andReturn(false);
$this->be($this->user());
@@ -27,8 +27,10 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
/**
@@ -57,6 +59,9 @@ class MassControllerTest extends TestCase
public function testDelete(): void
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
@@ -82,6 +87,8 @@ class MassControllerTest extends TestCase
// mock deletion:
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->andReturnValues([$deposits[0], $deposits[1]])->times(2);
$repository->shouldReceive('destroy')->times(2);
@@ -103,6 +110,8 @@ class MassControllerTest extends TestCase
public function testEdit(): void
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
$transfersArray = $transfers->pluck('id')->toArray();
@@ -140,6 +149,9 @@ class MassControllerTest extends TestCase
public function testEditMultiple(): void
{
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
@@ -188,6 +200,8 @@ class MassControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('update')->once();
$repository->shouldReceive('findNull')->once()->andReturn($deposit);
@@ -38,10 +38,12 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Log;
use Mockery;
use Steam;
use Tests\TestCase;
@@ -75,6 +77,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$account = $this->user()->accounts()->first();
@@ -107,6 +111,9 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
Steam::shouldReceive('phpBytes')->andReturn(2048);
@@ -133,6 +140,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
Steam::shouldReceive('phpBytes')->andReturn(2048);
@@ -158,6 +167,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
Steam::shouldReceive('phpBytes')->andReturn(2048);
@@ -182,6 +193,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -203,6 +216,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('destroy')->once();
@@ -228,6 +243,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('setUser')->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$account = $this->user()->accounts()->first();
@@ -273,6 +290,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -320,6 +339,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -367,6 +388,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('getTransactionType')->andReturn('Reconciliation')->once();
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
@@ -393,6 +416,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -423,6 +448,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -443,6 +470,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -491,6 +520,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -533,6 +564,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('setUser')->once();
@@ -583,6 +616,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// mock results:
@@ -619,6 +654,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// mock results:
@@ -674,6 +711,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// mock results:
@@ -729,6 +768,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// mock results:
@@ -785,6 +826,8 @@ class SingleControllerTest extends TestCase
$attRepos = $this->mock(AttachmentHelperInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// mock results:
@@ -845,6 +888,8 @@ class SingleControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
@@ -32,6 +32,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Log;
@@ -66,7 +67,10 @@ class SplitControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
@@ -112,6 +116,10 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
@@ -207,6 +215,8 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
$journalRepos->shouldReceive('firstNull')->once()->andReturn($opening);
@@ -225,6 +235,9 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$transactions = factory(Transaction::class, 1)->make();
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
@@ -269,6 +282,8 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
$ruleRepos->shouldReceive('setUser')->once();
@@ -323,6 +338,8 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
@@ -367,6 +384,7 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
$ruleRepos->shouldReceive('setUser')->once();
@@ -424,6 +442,8 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
$ruleRepos->shouldReceive('setUser')->once();