mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 19:49:54 +00:00
Fix test coverage.
This commit is contained in:
@@ -110,7 +110,7 @@ class SelectControllerTest extends TestCase
|
||||
public function testTestTriggers(): void
|
||||
{
|
||||
$data = [
|
||||
'rule_triggers' => [
|
||||
'triggers' => [
|
||||
'name' => 'description',
|
||||
'value' => 'Bla bla',
|
||||
'stop_processing' => 1,
|
||||
@@ -125,9 +125,9 @@ class SelectControllerTest extends TestCase
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
|
||||
$matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setStrict')->once()->withArgs([false])->andReturnSelf();
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
|
||||
@@ -145,8 +145,8 @@ class SelectControllerTest extends TestCase
|
||||
$matcher = $this->mock(TransactionMatcher::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setRule')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByRule')->andReturn(new Collection);
|
||||
|
||||
@@ -181,7 +181,7 @@ class SelectControllerTest extends TestCase
|
||||
public function testTestTriggersMax(): void
|
||||
{
|
||||
$data = [
|
||||
'rule_triggers' => [
|
||||
'triggers' => [
|
||||
'name' => 'description',
|
||||
'value' => 'Bla bla',
|
||||
'stop_processing' => 1,
|
||||
@@ -199,8 +199,8 @@ class SelectControllerTest extends TestCase
|
||||
|
||||
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
|
||||
|
||||
$matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn($set);
|
||||
|
||||
|
@@ -122,9 +122,16 @@ class MassControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$source]));
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$source]));
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn($transfers->first()->transactions()->first());
|
||||
|
||||
// get all kinds of meta fields (the transformer needs this)
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Hello');
|
||||
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturnNull();
|
||||
$journalRepos->shouldReceive('getMetaDateString')->withAnyArgs()->andReturnNull();
|
||||
|
||||
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
@@ -172,6 +179,11 @@ class MassControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('isJournalReconciled')
|
||||
->andReturn(true, false, false, false, false);
|
||||
|
||||
// get all kinds of meta fields (the transformer needs this)
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Hello');
|
||||
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturnNull();
|
||||
$journalRepos->shouldReceive('getMetaDateString')->withAnyArgs()->andReturnNull();
|
||||
|
||||
|
||||
// default transactions
|
||||
$collection = $this->user()->transactionJournals()->take(5)->get();
|
||||
|
@@ -1012,6 +1012,10 @@ class SingleControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getAttachments')->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('');
|
||||
$journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
|
||||
|
||||
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
|
||||
|
@@ -67,7 +67,7 @@ class SplitControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$attHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
@@ -89,11 +89,12 @@ class SplitControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
|
||||
$journalRepos->shouldReceive('getJournalCategoryName')->andReturn('Some');
|
||||
$journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
|
||||
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
@@ -116,14 +117,14 @@ 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 = $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;
|
||||
$transactions = factory(Transaction::class, 3)->make();
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
$transactions = factory(Transaction::class, 3)->make();
|
||||
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
|
||||
@@ -139,10 +140,11 @@ class SplitControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
|
||||
|
||||
|
||||
$old = [
|
||||
@@ -215,7 +217,7 @@ 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 = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
|
||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||
@@ -235,7 +237,7 @@ 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 = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
@@ -254,10 +256,11 @@ class SplitControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||
$journalRepos->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
@@ -282,7 +285,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);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
|
||||
$billRepos->shouldReceive('scan');
|
||||
@@ -338,7 +341,7 @@ 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 = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
@@ -384,7 +387,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);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('scan');
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
@@ -442,7 +445,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);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
|
||||
$billRepos->shouldReceive('scan');
|
||||
|
@@ -374,7 +374,8 @@ class TransactionControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.show', [1]));
|
||||
|
Reference in New Issue
Block a user