mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 16:10:00 +00:00
Fix actions and associated tests.
This commit is contained in:
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\SetDescription;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -32,37 +31,34 @@ use Tests\TestCase;
|
||||
*/
|
||||
class SetDescriptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
self::markTestIncomplete('Incomplete for refactor.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Actions\SetDescription
|
||||
*/
|
||||
public function testAct(): void
|
||||
{
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$newDescription = sprintf('new description #%d', $this->randomInt());
|
||||
$oldDescription = $withdrawal->description;
|
||||
|
||||
// get journal, give fixed description
|
||||
$description = 'text' . $this->randomInt();
|
||||
$newDescription = 'new description' . $this->randomInt();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journal->description = $description;
|
||||
$journal->save();
|
||||
$array = [
|
||||
'description' => $oldDescription,
|
||||
'transaction_journal_id' => $withdrawal->id,
|
||||
];
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $newDescription;
|
||||
$action = new SetDescription($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$result = $action->actOnArray($array);
|
||||
$this->assertTrue($result);
|
||||
$journal = TransactionJournal::find($journal->id);
|
||||
|
||||
$withdrawal->refresh();
|
||||
|
||||
// assert result
|
||||
$this->assertEquals($newDescription, $journal->description);
|
||||
$this->assertEquals($newDescription, $withdrawal->description);
|
||||
|
||||
$withdrawal->description = $oldDescription;
|
||||
$withdrawal->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user