. */ declare(strict_types=1); namespace Tests\Unit\TransactionRules\Actions; use FireflyIII\Models\RuleAction; use FireflyIII\Models\TransactionJournal; use FireflyIII\TransactionRules\Actions\PrependDescription; use Tests\TestCase; /** * Class PrependDescriptionTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class PrependDescriptionTest extends TestCase { /** * @covers \FireflyIII\TransactionRules\Actions\PrependDescription */ public function testAct(): void { // get journal, give fixed description $description = 'text' . $this->randomInt(); $prepend = 'prepend' . $this->randomInt(); $journal = $this->getRandomWithdrawal(); $journal->description = $description; $journal->save(); // fire the action: $ruleAction = new RuleAction; $ruleAction->action_value = $prepend; $action = new PrependDescription($ruleAction); $result = $action->act($journal); $this->assertTrue($result); $journal = TransactionJournal::find($journal->id); // assert result $this->assertEquals($prepend . $description, $journal->description); } }