mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Improve test coverage.
This commit is contained in:
@@ -24,8 +24,6 @@ namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Factory\TagFactory;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\AddTag;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@@ -49,42 +47,84 @@ class AddTagTest extends TestCase
|
||||
*/
|
||||
public function testActExistingTag(): void
|
||||
{
|
||||
$tag = $this->user()->tags()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$tag = $this->getRandomTag();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
||||
// make sure journal has no tags:
|
||||
$journal->tags()->sync([]);
|
||||
$journal->save();
|
||||
|
||||
// add single existing tag:
|
||||
$journal->tags()->sync([$tag->id]);
|
||||
|
||||
|
||||
$tagFactory->shouldReceive('setUser')->once();
|
||||
$tagFactory->shouldReceive('findOrCreate')->once()->withArgs([$tag->tag])->andReturn($tag);
|
||||
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal->tags()->sync([]);
|
||||
$journal->tags()->sync([$tag->id]);
|
||||
// assert connection exists.
|
||||
$this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
|
||||
|
||||
// file action
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $tag->tag;
|
||||
|
||||
$action = new AddTag($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
|
||||
// assert DB is unchanged.
|
||||
$this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\AddTag
|
||||
*/
|
||||
public function testActNewTag(): void
|
||||
{
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$tag = $this->getRandomTag();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
||||
// make sure journal has no tags:
|
||||
$journal->tags()->sync([]);
|
||||
$journal->save();
|
||||
|
||||
$tagFactory->shouldReceive('setUser')->once();
|
||||
$tagFactory->shouldReceive('findOrCreate')->once()->withArgs([$tag->tag])->andReturn($tag);
|
||||
|
||||
// assert connection does not exist.
|
||||
$this->assertDatabaseMissing('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
|
||||
|
||||
// file action
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $tag->tag;
|
||||
$action = new AddTag($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
||||
// assert DB is unchanged.
|
||||
$this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\AddTag
|
||||
*/
|
||||
public function testActNoTag(): void
|
||||
public function testActNullTag(): void
|
||||
{
|
||||
$newTagName = 'TestTag-' . $th;
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
// try to add non-existing tag
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$newTagName = 'TestTag-' . $this->randomInt();
|
||||
|
||||
// should return null:
|
||||
$tagFactory->shouldReceive('setUser')->once();
|
||||
$tagFactory->shouldReceive('findOrCreate')->once()->withArgs([$newTagName])->andReturnNull();
|
||||
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $newTagName;
|
||||
$action = new AddTag($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
||||
// find newly created tag:
|
||||
$tag = Tag::orderBy('id', 'DESC')->first();
|
||||
$this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
|
@@ -49,11 +49,10 @@ class AppendDescriptionTest extends TestCase
|
||||
{
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'APPEND';
|
||||
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$oldDescription = $journal->description;
|
||||
$action = new AppendDescription($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$oldDescription = $journal->description;
|
||||
$action = new AppendDescription($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$journal = TransactionJournal::find($journal->id);
|
||||
|
@@ -49,7 +49,7 @@ class AppendNotesTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// give journal some notes.
|
||||
$journal = TransactionJournal::find(3);
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$note = $journal->notes()->first();
|
||||
$start = 'Default note text';
|
||||
$toAppend = 'This is appended';
|
||||
|
@@ -49,8 +49,8 @@ class ClearBudgetTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// associate budget with journal:
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$budget = $journal->user->budgets()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$budget = $this->getRandomBudget();
|
||||
$journal->budgets()->save($budget);
|
||||
$this->assertGreaterThan(0, $journal->budgets()->count());
|
||||
|
||||
|
@@ -49,8 +49,8 @@ class ClearCategoryTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// associate budget with journal:
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$category = $journal->user->categories()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$category = $this->getRandomCategory();;
|
||||
$journal->categories()->save($category);
|
||||
$this->assertGreaterThan(0, $journal->categories()->count());
|
||||
|
||||
|
@@ -51,7 +51,7 @@ class ClearNotesTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// give journal a note:
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$note = $journal->notes()->first();
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
|
@@ -53,11 +53,8 @@ class ConvertToDepositTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToDeposit
|
||||
*/
|
||||
public function testActTransfer()
|
||||
public function testActTransfer(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . $this->randomInt();
|
||||
$journal = $this->getRandomTransfer();
|
||||
@@ -92,11 +89,8 @@ class ConvertToDepositTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToDeposit
|
||||
*/
|
||||
public function testActWithdrawal()
|
||||
public function testActWithdrawal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . $this->randomInt();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
@@ -27,6 +27,7 @@ namespace Tests\Unit\TransactionRules\Actions;
|
||||
use Exception;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -56,24 +57,21 @@ class ConvertToTransferTest extends TestCase
|
||||
*/
|
||||
public function testActDeposit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$deposit = $this->getRandomDeposit();
|
||||
/** @var Account $asset */
|
||||
$asset = $this->user()->accounts()->where('name', 'Bitcoin Account')->first();
|
||||
// journal is a withdrawal:
|
||||
$this->assertEquals(TransactionType::DEPOSIT, $deposit->transactionType->type);
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
// mock used stuff:
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])
|
||||
->andReturn($asset);
|
||||
$accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])->andReturn($asset);
|
||||
|
||||
// fire the action:
|
||||
$rule = new Rule;
|
||||
$rule->title = 'OK';
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $asset->name;
|
||||
$ruleAction->rule = $rule;
|
||||
$action = new ConvertToTransfer($ruleAction);
|
||||
|
||||
try {
|
||||
@@ -95,24 +93,21 @@ class ConvertToTransferTest extends TestCase
|
||||
*/
|
||||
public function testActWithdrawal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
/** @var Account $asset */
|
||||
$asset = $this->user()->accounts()->where('name', 'Bitcoin Account')->first();
|
||||
// journal is a withdrawal:
|
||||
$this->assertEquals(TransactionType::WITHDRAWAL, $withdrawal->transactionType->type);
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
// mock used stuff:
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])
|
||||
->andReturn($asset);
|
||||
$accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])->andReturn($asset);
|
||||
|
||||
// fire the action:
|
||||
$rule = new Rule;
|
||||
$rule->title = 'OK';
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $asset->name;
|
||||
$ruleAction->rule = $rule;
|
||||
$action = new ConvertToTransfer($ruleAction);
|
||||
|
||||
try {
|
||||
|
@@ -55,9 +55,6 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
*/
|
||||
public function testActDeposit()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$expense = $this->getRandomExpense();
|
||||
$name = 'Random expense #' . $this->randomInt();
|
||||
$deposit = $this->getRandomDeposit();
|
||||
@@ -94,16 +91,10 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
*/
|
||||
public function testActTransfer()
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$expense = $this->getRandomExpense();
|
||||
$name = 'Random expense #' . $this->randomInt();
|
||||
$transfer = $this->getRandomTransfer();
|
||||
|
||||
// journal is a transfer:
|
||||
$this->assertEquals(TransactionType::TRANSFER, $transfer->transactionType->type);
|
||||
|
||||
// mock used stuff:
|
||||
$factory = $this->mock(AccountFactory::class);
|
||||
$factory->shouldReceive('setUser')->once();
|
||||
|
95
tests/Unit/TransactionRules/Actions/LinkToBillTest.php
Normal file
95
tests/Unit/TransactionRules/Actions/LinkToBillTest.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* LinkToBillTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Actions\LinkToBill;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class LinkToBillTest
|
||||
*/
|
||||
class LinkToBillTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\LinkToBill
|
||||
*/
|
||||
public function testBasic(): void
|
||||
{
|
||||
$repos = $this->mock(BillRepositoryInterface::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$rule = $this->getRandomRule();
|
||||
$bill = $this->getRandomBill();
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->rule = $rule;
|
||||
$ruleAction->action_type = 'link_to_bill';
|
||||
$ruleAction->action_value = $bill->name;
|
||||
|
||||
$repos->shouldReceive('setUser');
|
||||
$repos->shouldReceive('findByName')->withArgs([$bill->name])->andReturn($bill);
|
||||
|
||||
$action = new LinkToBill($ruleAction);
|
||||
$result = $action->act($withdrawal);
|
||||
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\LinkToBill
|
||||
*/
|
||||
public function testNoBill(): void
|
||||
{
|
||||
$repos = $this->mock(BillRepositoryInterface::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$rule = $this->getRandomRule();
|
||||
$bill = $this->getRandomBill();
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->rule = $rule;
|
||||
$ruleAction->action_type = 'link_to_bill';
|
||||
$ruleAction->action_value = $bill->name;
|
||||
|
||||
$repos->shouldReceive('setUser');
|
||||
$repos->shouldReceive('findByName')->withArgs([$bill->name])->andReturnNull();
|
||||
|
||||
$action = new LinkToBill($ruleAction);
|
||||
$result = $action->act($withdrawal);
|
||||
|
||||
$this->assertFalse($result);
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -39,8 +39,8 @@ class PrependDescriptionTest extends TestCase
|
||||
{
|
||||
// get journal, give fixed description
|
||||
$description = 'text' . $this->randomInt();
|
||||
$prepend = 'prepend' . random_int(1, 1234);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$prepend = 'prepend' . $this->randomInt();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->description = $description;
|
||||
$journal->save();
|
||||
|
||||
|
@@ -39,7 +39,7 @@ class PrependNotesTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// give journal some notes.
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$note = $journal->notes()->first();
|
||||
$start = 'Default note text';
|
||||
$toPrepend = 'This is prepended';
|
||||
@@ -62,13 +62,12 @@ class PrependNotesTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\PrependNotes()
|
||||
* @covers \FireflyIII\TransactionRules\Actions\PrependNotes
|
||||
*/
|
||||
public function testActNewNote(): void
|
||||
{
|
||||
// give journal some notes.
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$note = $journal->notes()->first();
|
||||
if (null !== $note) {
|
||||
$note->forceDelete();
|
||||
|
@@ -60,21 +60,20 @@ class RemoveTagTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\RemoveTag()
|
||||
* @covers \FireflyIII\TransactionRules\Actions\RemoveTag
|
||||
*/
|
||||
public function testActNoTag(): void
|
||||
{
|
||||
// get journal, link al tags:
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$tags = $journal->user->tags()->get();
|
||||
$journal->tags()->sync($tags->pluck('id')->toArray());
|
||||
$this->assertEquals($tags->count(), $journal->tags()->get()->count());
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = random_int(1, 1234) . 'nosuchtag';
|
||||
$ruleAction->action_value = $this->randomInt() . 'nosuchtag';
|
||||
$action = new RemoveTag($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
@@ -24,7 +24,6 @@ namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Actions\SetBudget;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -41,8 +40,57 @@ class SetBudgetTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// get journal, remove all budgets
|
||||
$journal = TransactionJournal::inRandomOrder()->where('transaction_type_id', 1)->whereNull('deleted_at')->first();
|
||||
$budget = $journal->user->budgets()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$budget = $this->getRandomBudget();
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('setUser');
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection([$budget]));
|
||||
|
||||
$journal->budgets()->sync([]);
|
||||
$this->assertEquals(0, $journal->budgets()->count());
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $budget->name;
|
||||
$action = new SetBudget($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals(1, $journal->budgets()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetBudget
|
||||
*/
|
||||
public function testActNull(): void
|
||||
{
|
||||
// get journal, remove all budgets
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$budget = $this->getRandomBudget();
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('setUser');
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
|
||||
$journal->budgets()->sync([]);
|
||||
$this->assertEquals(0, $journal->budgets()->count());
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $budget->name;
|
||||
$action = new SetBudget($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
$this->assertEquals(0, $journal->budgets()->count());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetBudget
|
||||
*/
|
||||
public function testActDeposit(): void
|
||||
{
|
||||
// get journal, remove all budgets
|
||||
$journal = $this->getRandomDeposit();
|
||||
$budget = $this->getRandomBudget();
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('setUser');
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection([$budget]));
|
||||
@@ -56,10 +104,6 @@ class SetBudgetTest extends TestCase
|
||||
$action = new SetBudget($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$this->assertEquals(1, $transaction->budgets()->count());
|
||||
$this->assertEquals($budget->name, $transaction->budgets()->first()->name);
|
||||
}
|
||||
$this->assertEquals(0, $journal->budgets()->count());
|
||||
}
|
||||
}
|
||||
|
@@ -22,9 +22,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\SetCategory;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -39,8 +38,13 @@ class SetCategoryTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// get journal, remove all budgets
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$category = $journal->user->categories()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$category = $this->getRandomCategory();
|
||||
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$factory->shouldReceive('setUser');
|
||||
$factory->shouldReceive('findOrCreate')->andReturn($category);
|
||||
|
||||
$journal->categories()->detach();
|
||||
$this->assertEquals(0, $journal->categories()->count());
|
||||
|
||||
@@ -51,12 +55,31 @@ class SetCategoryTest extends TestCase
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$this->assertEquals(1, $transaction->categories()->count());
|
||||
$this->assertEquals($category->name, $transaction->categories()->first()->name);
|
||||
}
|
||||
$this->assertEquals(1, $journal->categories()->count());
|
||||
}
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetCategory
|
||||
*/
|
||||
public function testActNull(): void
|
||||
{
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$factory->shouldReceive('setUser');
|
||||
$factory->shouldReceive('findOrCreate')->andReturnNull();
|
||||
|
||||
|
||||
// get journal, remove all budgets
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$category = $this->getRandomCategory();
|
||||
$journal->categories()->detach();
|
||||
$this->assertEquals(0, $journal->categories()->count());
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $category->name;
|
||||
$action = new SetCategory($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$this->assertEquals(0, $journal->categories()->count());
|
||||
}
|
||||
}
|
||||
|
@@ -39,8 +39,8 @@ class SetDescriptionTest extends TestCase
|
||||
{
|
||||
// get journal, give fixed description
|
||||
$description = 'text' . $this->randomInt();
|
||||
$newDescription = 'new description' . random_int(1, 1234);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$newDescription = 'new description' . $this->randomInt();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->description = $description;
|
||||
$journal->save();
|
||||
|
||||
|
@@ -45,9 +45,6 @@ class SetDestinationAccountTest extends TestCase
|
||||
*/
|
||||
public function testActDepositExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$destinationTr = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
@@ -82,9 +79,6 @@ class SetDestinationAccountTest extends TestCase
|
||||
*/
|
||||
public function testActDepositNotExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$deposit = $this->getRandomDeposit();
|
||||
|
||||
@@ -107,11 +101,8 @@ class SetDestinationAccountTest extends TestCase
|
||||
*/
|
||||
public function testActWithDrawalNotExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->inRandomOrder()->where('account_type_id', 4)->first();
|
||||
$account = $this->getRandomExpense();
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
// find account? Return account:
|
||||
@@ -135,9 +126,6 @@ class SetDestinationAccountTest extends TestCase
|
||||
*/
|
||||
public function testActWithdrawalExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$destinationTr = $withdrawal->transactions()->where('amount', '>', 0)->first();
|
||||
@@ -165,30 +153,4 @@ class SetDestinationAccountTest extends TestCase
|
||||
$this->assertEquals($newDestination->id, $account->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test this on a split journal.
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount
|
||||
*/
|
||||
public function testSplitJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transaction = Transaction::orderBy('count', 'DESC')->groupBy('transaction_journal_id')
|
||||
->get(['transaction_journal_id', DB::raw('COUNT(transaction_journal_id) as count')])
|
||||
->first();
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
|
||||
// mock
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new asset ' . $this->randomInt();
|
||||
$action = new SetDestinationAccount($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class SetNotesTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// give journal a note:
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$note = $journal->notes()->first();
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
@@ -51,7 +51,7 @@ class SetNotesTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'These are new notes ' . random_int(1, 1234);
|
||||
$ruleAction->action_value = 'These are new notes ' . $this->randomInt();
|
||||
$action = new SetNotes($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
@@ -68,13 +68,13 @@ class SetNotesTest extends TestCase
|
||||
public function testActNoNotes(): void
|
||||
{
|
||||
// give journal a note:
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->forceDelete();
|
||||
$this->assertEquals(0, $journal->notes()->count());
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'These are new notes ' . random_int(1, 1234);
|
||||
$ruleAction->action_value = 'These are new notes ' . $this->randomInt();
|
||||
$action = new SetNotes($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertTrue($result);
|
||||
|
@@ -43,9 +43,6 @@ class SetSourceAccountTest extends TestCase
|
||||
*/
|
||||
public function testActDepositExistingUpdated(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$sourceTr = $deposit->transactions()->where('amount', '<', 0)->first();
|
||||
@@ -80,11 +77,8 @@ class SetSourceAccountTest extends TestCase
|
||||
*/
|
||||
public function testActDepositRevenue(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->inRandomOrder()->where('account_type_id', 5)->first();
|
||||
$account = $this->getRandomRevenue();
|
||||
$deposit = $this->getRandomDeposit();
|
||||
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
@@ -106,9 +100,6 @@ class SetSourceAccountTest extends TestCase
|
||||
*/
|
||||
public function testActWithdrawalExistingUpdated(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
@@ -144,9 +135,6 @@ class SetSourceAccountTest extends TestCase
|
||||
*/
|
||||
public function testActWithdrawalNotExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
@@ -160,30 +148,4 @@ class SetSourceAccountTest extends TestCase
|
||||
$result = $action->act($withdrawal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test this on a split journal.
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount
|
||||
*/
|
||||
public function testSplitJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transaction = Transaction::orderBy('count', 'DESC')->groupBy('transaction_journal_id')
|
||||
->get(['transaction_journal_id', DB::raw('COUNT(transaction_journal_id) as count')])
|
||||
->first();
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
|
||||
// mock
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new asset ' . $this->randomInt();
|
||||
$action = new SetSourceAccount($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
|
@@ -37,8 +37,8 @@ class HasAnyCategoryTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$category = $journal->user->categories()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$category = $this->getRandomCategory();;
|
||||
$journal->categories()->detach();
|
||||
$journal->categories()->save($category);
|
||||
|
||||
@@ -53,7 +53,7 @@ class HasAnyCategoryTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->categories()->detach();
|
||||
|
||||
// also detach transactions:
|
||||
|
@@ -36,7 +36,7 @@ class HasAnyTagTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$tag = $journal->user->tags()->first();
|
||||
$journal->tags()->detach();
|
||||
$journal->tags()->save($tag);
|
||||
@@ -52,7 +52,7 @@ class HasAnyTagTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->tags()->detach();
|
||||
$this->assertEquals(0, $journal->tags()->count());
|
||||
$trigger = HasAnyTag::makeFromStrings('', false);
|
||||
|
@@ -38,7 +38,7 @@ class HasNoBudgetTest extends TestCase
|
||||
public function testTriggeredBudget(): void
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->whereNull('deleted_at')->first();
|
||||
$budget = $journal->user->budgets()->first();
|
||||
$budget = $this->getRandomBudget();
|
||||
$journal->budgets()->detach();
|
||||
$journal->budgets()->save($budget);
|
||||
$this->assertEquals(1, $journal->budgets()->count());
|
||||
|
@@ -37,8 +37,8 @@ class HasNoCategoryTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredCategory(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$category = $journal->user->categories()->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$category = $this->getRandomCategory();;
|
||||
$journal->categories()->detach();
|
||||
$journal->categories()->save($category);
|
||||
$this->assertEquals(1, $journal->categories()->count());
|
||||
@@ -53,7 +53,7 @@ class HasNoCategoryTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNoCategory(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->categories()->detach();
|
||||
|
||||
// also detach transactions:
|
||||
|
@@ -36,7 +36,7 @@ class HasNoTagTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNoTag(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->tags()->detach();
|
||||
$this->assertEquals(0, $journal->tags()->count());
|
||||
|
||||
@@ -50,7 +50,7 @@ class HasNoTagTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredTag(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$tag = $journal->user->tags()->first();
|
||||
$journal->tags()->detach();
|
||||
$journal->tags()->save($tag);
|
||||
|
@@ -37,7 +37,7 @@ class NotesAnyTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -53,7 +53,7 @@ class NotesAnyTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredEmpty(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -69,7 +69,7 @@ class NotesAnyTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNone(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$trigger = NotesAny::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
|
@@ -37,7 +37,7 @@ class NotesAreTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -53,7 +53,7 @@ class NotesAreTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredDifferent(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -69,7 +69,7 @@ class NotesAreTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredEmpty(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -85,7 +85,7 @@ class NotesAreTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNone(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$trigger = NotesAre::makeFromStrings('Bla bla', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
|
@@ -37,7 +37,7 @@ class NotesContainTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -53,7 +53,7 @@ class NotesContainTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredDifferent(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -69,7 +69,7 @@ class NotesContainTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredEmpty(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -85,7 +85,7 @@ class NotesContainTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNone(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$trigger = NotesContain::makeFromStrings('Bla bla', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
@@ -97,7 +97,7 @@ class NotesContainTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredPartial(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
|
@@ -37,7 +37,7 @@ class NotesEmptyTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$trigger = NotesEmpty::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
@@ -49,7 +49,7 @@ class NotesEmptyTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredEmpty(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -65,7 +65,7 @@ class NotesEmptyTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredPartial(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
|
@@ -37,7 +37,7 @@ class NotesEndTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -53,7 +53,7 @@ class NotesEndTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -69,7 +69,7 @@ class NotesEndTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNoMatch(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
|
@@ -37,7 +37,7 @@ class NotesStartTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -53,7 +53,7 @@ class NotesStartTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
@@ -69,7 +69,7 @@ class NotesStartTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNoMatch(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
|
@@ -37,7 +37,7 @@ class TagIsTest extends TestCase
|
||||
*/
|
||||
public function testNotTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->tags()->detach();
|
||||
$this->assertEquals(0, $journal->tags()->count());
|
||||
|
||||
@@ -51,7 +51,7 @@ class TagIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->tags()->detach();
|
||||
/** @var Collection $tags */
|
||||
$tags = $journal->user->tags()->take(3)->get();
|
||||
|
@@ -82,7 +82,7 @@ class ToAccountEndsTest extends TestCase
|
||||
$collection = new Collection([$account]);
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->once()->andReturn($collection);
|
||||
|
||||
$trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 1234), false);
|
||||
$trigger = ToAccountEnds::makeFromStrings((string)$this->randomInt(), false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class TransactionTypeTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$type = $journal->transactionType->type;
|
||||
$trigger = TransactionType::makeFromStrings($type, false);
|
||||
$result = $trigger->triggered($journal);
|
||||
@@ -48,7 +48,7 @@ class TransactionTypeTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredFalse(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$trigger = TransactionType::makeFromStrings('NonExisting', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
|
Reference in New Issue
Block a user