mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Update tests.
This commit is contained in:
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Unit\TransactionRules\Actions;
|
namespace Tests\Unit\TransactionRules\Actions;
|
||||||
|
|
||||||
|
use FireflyIII\Factory\TagFactory;
|
||||||
use FireflyIII\Models\RuleAction;
|
use FireflyIII\Models\RuleAction;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
@@ -40,6 +41,12 @@ class AddTagTest extends TestCase
|
|||||||
public function testActExistingTag(): void
|
public function testActExistingTag(): void
|
||||||
{
|
{
|
||||||
$tag = $this->user()->tags()->inRandomOrder()->whereNull('deleted_at')->first();
|
$tag = $this->user()->tags()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
|
$tagFactory = $this->mock(TagFactory::class);
|
||||||
|
$tagFactory->shouldReceive('setUser')->once();
|
||||||
|
$tagFactory->shouldReceive('findOrCreate')->once()->withArgs([$tag->tag])->andReturn($tag);
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
$journal->tags()->sync([]);
|
$journal->tags()->sync([]);
|
||||||
@@ -59,9 +66,10 @@ class AddTagTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testActNoTag(): void
|
public function testActNoTag(): void
|
||||||
{
|
{
|
||||||
|
$newTagName = 'TestTag-' . random_int(1, 10000);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
$ruleAction = new RuleAction;
|
$ruleAction = new RuleAction;
|
||||||
$ruleAction->action_value = 'TestTag-' . random_int(1, 10000);
|
$ruleAction->action_value = $newTagName;
|
||||||
$action = new AddTag($ruleAction);
|
$action = new AddTag($ruleAction);
|
||||||
$result = $action->act($journal);
|
$result = $action->act($journal);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
Reference in New Issue
Block a user