Fix actions and associated tests.

This commit is contained in:
James Cole
2020-08-23 16:12:16 +02:00
parent 139b3ffab4
commit fecc9f7659
8 changed files with 286 additions and 318 deletions

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions;
use DB;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
use Log;
@@ -31,8 +32,7 @@ use Log;
*/
class SetDescription implements ActionInterface
{
/** @var RuleAction The rule action */
private $action;
private RuleAction $action;
/**
* TriggerInterface constructor.
@@ -46,10 +46,11 @@ class SetDescription implements ActionInterface
/**
* Set description to X
*
* @param TransactionJournal $journal
*
* @return bool
* @deprecated
* @codeCoverageIgnore
*/
public function act(TransactionJournal $journal): bool
{
@@ -75,6 +76,18 @@ class SetDescription implements ActionInterface
*/
public function actOnArray(array $journal): bool
{
// TODO: Implement actOnArray() method.
DB::table('transaction_journals')
->where('id', '=', $journal['transaction_journal_id'])
->update(['description' => $this->action->action_value]);
Log::debug(
sprintf(
'RuleAction SetDescription changed the description of journal #%d from "%s" to "%s".',
$journal['transaction_journal_id'],
$journal['description'],
$this->action->action_value
)
);
return true;
}
}