New unit tests.

This commit is contained in:
James Cole
2017-10-04 15:27:20 +02:00
parent 6770b8396a
commit c17a278e57
18 changed files with 1098 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
use Log;
@@ -45,8 +46,11 @@ class ClearNotes implements ActionInterface
public function act(TransactionJournal $journal): bool
{
Log::debug(sprintf('RuleAction ClearNotes removed all notes.'));
$journal->deleteMeta('notes');
$journal->save();
$notes = $journal->notes()->get();
/** @var Note $note */
foreach ($notes as $note) {
$note->delete();
}
return true;
}

View File

@@ -45,8 +45,7 @@ class SetDescription implements ActionInterface
*/
public function act(TransactionJournal $journal): bool
{
$oldDescription = $journal->description;
$oldDescription = $journal->description;
$journal->description = $this->action->action_value;
$journal->save();

View File

@@ -66,7 +66,7 @@ class SetDestinationAccount implements ActionInterface
if ($count > 2) {
Log::error(sprintf('Cannot change destination account of journal #%d because it is a split journal.', $journal->id));
return true;
return false;
}
// journal type:
@@ -81,7 +81,7 @@ class SetDestinationAccount implements ActionInterface
)
);
return true;
return false;
}
// if this is a withdrawal, the new destination account must be a expense account and may be created:

View File

@@ -66,7 +66,7 @@ class SetSourceAccount implements ActionInterface
if ($count > 2) {
Log::error(sprintf('Cannot change source account of journal #%d because it is a split journal.', $journal->id));
return true;
return false;
}
// journal type:
@@ -80,7 +80,7 @@ class SetSourceAccount implements ActionInterface
)
);
return true;
return false;
}
// if this is a deposit, the new source account must be a revenue account and may be created: