{% if tag.latitude and tag.longitude and tag.zoomLevel %}
-
+
{% else %}
{{ 'no_location_set'|_ }}
{% endif %}
@@ -195,6 +195,9 @@
{% endif %}
{% endblock %}
+{% block styles %}
+
+{% endblock %}
{% block scripts %}
-
+
{% endblock %}
diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig
index 3416cc4284..01f6e8e57f 100644
--- a/resources/views/transactions/show.twig
+++ b/resources/views/transactions/show.twig
@@ -235,13 +235,11 @@
{{ journal.getMeta('internal_reference') }} |
{% endif %}
-
- {% if journal.hasMeta('notes') and journal.getMeta('notes') != "" %}
+ {% if journal.notes.count == 1 %}
{{ trans('list.notes') }} |
- {{ journal.getMeta('notes')|nl2br }} |
+ {{ journal.notes.first.markdown|raw }} |
-
{% endif %}
{% if journal.bill %}
diff --git a/test.sh b/test.sh
index ea9dbe9ddf..9b0b2836c7 100755
--- a/test.sh
+++ b/test.sh
@@ -112,7 +112,7 @@ echo "clear caches and what-not.."
php artisan cache:clear
php artisan config:clear
php artisan route:clear
-php artisan twig:clean
+# php artisan twig:clean
php artisan view:clear
# run PHPUnit
@@ -138,4 +138,4 @@ fi
# restore current config:
if [ -f $BACKUPENV ]; then
mv $BACKUPENV $ORIGINALENV
-fi
\ No newline at end of file
+fi
diff --git a/tests/Feature/Controllers/BudgetControllerTest.php b/tests/Feature/Controllers/BudgetControllerTest.php
index acb687037c..5db4645cd2 100644
--- a/tests/Feature/Controllers/BudgetControllerTest.php
+++ b/tests/Feature/Controllers/BudgetControllerTest.php
@@ -136,7 +136,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
@@ -184,7 +183,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
@@ -232,7 +230,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
diff --git a/tests/Feature/Controllers/JavascriptControllerTest.php b/tests/Feature/Controllers/JavascriptControllerTest.php
index 73e37f9282..dd7b52b121 100644
--- a/tests/Feature/Controllers/JavascriptControllerTest.php
+++ b/tests/Feature/Controllers/JavascriptControllerTest.php
@@ -63,7 +63,7 @@ class JavascriptControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
- * @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangePicker
+ * @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
*
* @param string $range
*
diff --git a/tests/Feature/Controllers/NewUserControllerTest.php b/tests/Feature/Controllers/NewUserControllerTest.php
index 7a18d8824f..d76919f9d3 100644
--- a/tests/Feature/Controllers/NewUserControllerTest.php
+++ b/tests/Feature/Controllers/NewUserControllerTest.php
@@ -68,7 +68,6 @@ class NewUserControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\NewUserController::submit
* @covers \FireflyIII\Http\Controllers\NewUserController::createAssetAccount
* @covers \FireflyIII\Http\Controllers\NewUserController::createSavingsAccount
- * @covers \FireflyIII\Http\Controllers\NewUserController::storeCreditCard
*/
public function testSubmit()
{
diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.php
index 5f335c10bc..56aa6fea86 100644
--- a/tests/Feature/Controllers/TagControllerTest.php
+++ b/tests/Feature/Controllers/TagControllerTest.php
@@ -107,6 +107,7 @@ class TagControllerTest extends TestCase
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('count')->andReturn(0);
$repository->shouldReceive('tagCloud')->andReturn([]);
+ $repository->shouldReceive('oldestTag')->andReturn(null)->once();
$this->be($this->user());
$response = $this->get(route('tags.index'));
@@ -137,9 +138,7 @@ class TagControllerTest extends TestCase
$repository->shouldReceive('earnedInPeriod')->andReturn('1')->once();
$repository->shouldReceive('sumsOfTag')->andReturn($amounts)->once();
-
$collector->shouldReceive('removeFilter')->andReturnSelf()->once();
-
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setPage')->andReturnSelf()->once();
diff --git a/tests/Unit/Import/Converter/AmountTest.php b/tests/Unit/Import/Converter/AmountTest.php
new file mode 100644
index 0000000000..f9bb4dcbac
--- /dev/null
+++ b/tests/Unit/Import/Converter/AmountTest.php
@@ -0,0 +1,95 @@
+ '0',
+ '0.0' => '0',
+ '0.1' => '0.1',
+ '.2' => '0.2',
+ '0.01' => '0.01',
+ '1' => '1',
+ '1.0' => '1',
+ '1.1' => '1.1',
+ '1.12' => '1.12',
+ '1.10' => '1.1',
+ '12' => '12',
+ '12.3' => '12.3',
+ '12.34' => '12.34',
+ '123' => '123',
+ '123.4' => '123.4',
+ '123.45' => '123.45',
+ '1234' => '1234',
+ '1234.5' => '1234.5',
+ '1234.56' => '1234.56',
+ '1 234' => '1234',
+ '1 234.5' => '1234.5',
+ '1 234.56' => '1234.56',
+ '1,234' => '1234',
+ '1,234.5' => '1234.5',
+ '1,234.56' => '1234.56',
+ '0,0' => '0',
+ '0,1' => '0.1',
+ ',2' => '0.2',
+ '0,01' => '0.01',
+ '1,0' => '1',
+ '1,1' => '1.1',
+ '1,12' => '1.12',
+ '1,10' => '1.1',
+ '12,3' => '12.3',
+ '12,34' => '12.34',
+ '123,4' => '123.4',
+ '123,45' => '123.45',
+ '1234,5' => '1234.5',
+ '1234,56' => '1234.56',
+ '1 234,5' => '1234.5',
+ '1 234,56' => '1234.56',
+ '1.234' => '1234',
+ '1.234,5' => '1234.5',
+ '1.234,56' => '1234.56',
+
+ ];
+ foreach ($values as $value => $expected) {
+ $converter = new Amount;
+ $result = $converter->convert($value);
+ $this->assertEquals($expected, $result);
+ }
+ }
+
+ /**
+ * @covers \FireflyIII\Import\Converter\Amount::convert()
+ */
+ public function testConvertNull()
+ {
+ $converter = new Amount;
+ $result = $converter->convert(null);
+ $this->assertEquals('0', $result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/AddTagTest.php b/tests/Unit/TransactionRules/Actions/AddTagTest.php
new file mode 100644
index 0000000000..e8b9352879
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/AddTagTest.php
@@ -0,0 +1,59 @@
+assertDatabaseHas('tag_transaction_journal', ['tag_id' => 2, 'transaction_journal_id' => 1]);
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'housing';
+ $journal = TransactionJournal::find(1);
+ $action = new AddTag($ruleAction);
+ $result = $action->act($journal);
+ $this->assertFalse($result);
+ $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => 2, 'transaction_journal_id' => 1]);
+
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Actions\AddTag::act()
+ */
+ public function testActNoTag()
+ {
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'TestTag-' . rand(1, 1000);
+ $journal = TransactionJournal::find(1);
+ $action = new AddTag($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // find newly created tag:
+ $tag = Tag::orderBy('id', 'DESC')->first();
+ $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => 1]);
+
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php b/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php
new file mode 100644
index 0000000000..3d191319a4
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php
@@ -0,0 +1,43 @@
+action_value = 'APPEND';
+
+ $journal = TransactionJournal::find(1);
+ $oldDescription = $journal->description;
+ $action = new AppendDescription($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $journal = TransactionJournal::find(1);
+ $this->assertEquals($oldDescription . 'APPEND', $journal->description);
+
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/AppendNotesTest.php b/tests/Unit/TransactionRules/Actions/AppendNotesTest.php
new file mode 100644
index 0000000000..093e9f32d8
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/AppendNotesTest.php
@@ -0,0 +1,84 @@
+notes()->first();
+ $start = 'Default note text';
+ $toAppend = 'This is appended';
+ if (is_null($note)) {
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ }
+ $note->text = $start;
+ $note->save();
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $toAppend;
+ $action = new AppendNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $newNote = $journal->notes()->first();
+ $this->assertEquals($start . $toAppend, $newNote->text);
+
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Actions\AppendNotes::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\AppendNotes::act()
+ */
+ public function testActNewNote()
+ {
+ // give journal some notes.
+ $journal = TransactionJournal::find(4);
+ $note = $journal->notes()->first();
+ if (!is_null($note)) {
+ $note->forceDelete();
+ }
+ $toAppend = 'This is appended';
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $toAppend;
+ $action = new AppendNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $newNote = $journal->notes()->first();
+ $this->assertEquals($toAppend, $newNote->text);
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
new file mode 100644
index 0000000000..1b00597916
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
@@ -0,0 +1,51 @@
+user->budgets()->first();
+ $journal->budgets()->save($budget);
+ $this->assertGreaterThan(0, $journal->budgets()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = null;
+ $action = new ClearBudget($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // assert result
+ $this->assertEquals(0, $journal->budgets()->count());
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
new file mode 100644
index 0000000000..294e3b984f
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
@@ -0,0 +1,49 @@
+user->categories()->first();
+ $journal->budgets()->save($category);
+ $this->assertGreaterThan(0, $journal->categories()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = null;
+ $action = new ClearCategory($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // assert result
+ $this->assertEquals(0, $journal->categories()->count());
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/ClearNotesTest.php b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php
new file mode 100644
index 0000000000..41c6d8bc22
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php
@@ -0,0 +1,57 @@
+notes()->first();
+ if (is_null($note)) {
+ $note = new Note;
+ $note->noteable()->associate($journal);
+ }
+ $note->text = 'Hello test note';
+ $note->save();
+ $this->assertEquals(1, $journal->notes()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = null;
+ $action = new ClearNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // assert result
+ $this->assertEquals(0, $journal->notes()->count());
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php b/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php
new file mode 100644
index 0000000000..d6063ef3fa
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php
@@ -0,0 +1,53 @@
+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(7);
+
+ // assert result
+ $this->assertEquals($prepend.$description, $journal->description);
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/PrependNotesTest.php b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php
new file mode 100644
index 0000000000..0d42bb23ee
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php
@@ -0,0 +1,84 @@
+notes()->first();
+ $start = 'Default note text';
+ $toPrepend = 'This is prepended';
+ if (is_null($note)) {
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ }
+ $note->text = $start;
+ $note->save();
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $toPrepend;
+ $action = new PrependNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $newNote = $journal->notes()->first();
+ $this->assertEquals($toPrepend . $start, $newNote->text);
+
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Actions\PrependNotes::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\PrependNotes::act()
+ */
+ public function testActNewNote()
+ {
+ // give journal some notes.
+ $journal = TransactionJournal::find(4);
+ $note = $journal->notes()->first();
+ if (!is_null($note)) {
+ $note->forceDelete();
+ }
+ $toPrepend = 'This is appended';
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $toPrepend;
+ $action = new PrependNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $newNote = $journal->notes()->first();
+ $this->assertEquals($toPrepend, $newNote->text);
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php b/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php
new file mode 100644
index 0000000000..7f754deb47
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php
@@ -0,0 +1,52 @@
+user->tags()->get();
+ foreach ($tags as $tag) {
+ $journal->tags()->save($tag);
+ $journal->save();
+ }
+ $this->assertGreaterThan(0, $journal->tags()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = null;
+ $action = new RemoveAllTags($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ $this->assertEquals(0, $journal->tags()->count());
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/RemoveTagTest.php b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php
new file mode 100644
index 0000000000..68d83b9dcb
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php
@@ -0,0 +1,80 @@
+user->tags()->get();
+ foreach ($tags as $tag) {
+ $journal->tags()->save($tag);
+ $journal->save();
+ }
+ $firstTag = $tags->first();
+ $oldCount = $journal->tags()->count();
+ $this->assertGreaterThan(0, $journal->tags()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $firstTag->tag;
+ $action = new RemoveTag($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+ foreach ($journal->tags()->get() as $tag) {
+ $this->assertNotEquals($firstTag->id, $tag->id);
+ }
+ $this->assertEquals(($oldCount - 1), $journal->tags()->count());
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Actions\RemoveTag::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\RemoveTag::act()
+ */
+ public function testActNoTag()
+ {
+ // get journal, link al tags:
+ $journal = TransactionJournal::find(11);
+ $tags = $journal->user->tags()->get();
+ foreach ($tags as $tag) {
+ $journal->tags()->save($tag);
+ $journal->save();
+ }
+ $this->assertEquals($tags->count(), $journal->tags()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = rand(1, 1234) . 'nosuchtag';
+ $action = new RemoveTag($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+ $this->assertEquals($tags->count(), $journal->tags()->count());
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetBudgetTest.php b/tests/Unit/TransactionRules/Actions/SetBudgetTest.php
new file mode 100644
index 0000000000..d00b55cf99
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetBudgetTest.php
@@ -0,0 +1,49 @@
+user->budgets()->first();
+ $journal->budgets()->detach();
+ $this->assertEquals(0, $journal->budgets()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $budget->name;
+ $action = new SetBudget($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+ $this->assertEquals(1, $journal->budgets()->count());
+ $this->assertEquals($budget->name, $journal->budgets()->first()->name);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetCategoryTest.php b/tests/Unit/TransactionRules/Actions/SetCategoryTest.php
new file mode 100644
index 0000000000..eed0a0e65a
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetCategoryTest.php
@@ -0,0 +1,48 @@
+user->categories()->first();
+ $journal->categories()->detach();
+ $this->assertEquals(0, $journal->categories()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $category->name;
+ $action = new SetCategory($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+ $this->assertEquals(1, $journal->categories()->count());
+ $this->assertEquals($category->name, $journal->categories()->first()->name);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php b/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php
new file mode 100644
index 0000000000..92c7037173
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php
@@ -0,0 +1,52 @@
+description = $description;
+ $journal->save();
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $newDescription;
+ $action = new SetDescription($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+ $journal = TransactionJournal::find(14);
+
+ // assert result
+ $this->assertEquals($newDescription, $journal->description);
+
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php b/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php
new file mode 100644
index 0000000000..91dc27d940
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php
@@ -0,0 +1,175 @@
+first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $destinationTr->account;
+ $user = $journal->user;
+ $accountType = AccountType::whereType(AccountType::ASSET)->first();
+ $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $destination->id)->first();
+ $this->assertNotEquals($destination->id, $account->id);
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $account->name;
+ $action = new SetDestinationAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $newDestination = $destinationTr->account;
+ $this->assertNotEquals($destination->id, $newDestination->id);
+ $this->assertEquals($newDestination->id, $account->id);
+ }
+
+ /**
+ * Give deposit new asset account (will fail)
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::findAssetAccount()
+ */
+ public function testActDepositNew()
+ {
+ $type = TransactionType::whereType(TransactionType::DEPOSIT)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $destinationTr->account;
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new asset ' . rand(1, 1000);
+ $action = new SetDestinationAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertFalse($result);
+
+ // test journal for still having old account
+ $journal = TransactionJournal::find($journal->id);
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $newDestination = $destinationTr->account;
+ $this->assertEquals($destination->id, $newDestination->id);
+ }
+
+ /**
+ * Give withdrawal existing expense account.
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::findExpenseAccount
+ */
+ public function testActWithdrawalExisting()
+ {
+ $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $destinationTr->account;
+ $user = $journal->user;
+ $accountType = AccountType::whereType(AccountType::EXPENSE)->first();
+ $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $destination->id)->first();
+ $this->assertNotEquals($destination->id, $account->id);
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $account->name;
+ $action = new SetDestinationAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $newDestination = $destinationTr->account;
+ $this->assertNotEquals($destination->id, $newDestination->id);
+ $this->assertEquals($newDestination->id, $account->id);
+ }
+
+ /**
+ * Give withdrawal new expense account.
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::findExpenseAccount
+ */
+ public function testActWithdrawalNew()
+ {
+ $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $destinationTr->account;
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new expense ' . rand(1, 1000);
+ $action = new SetDestinationAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $destinationTr = $journal->transactions()->where('amount', '>', 0)->first();
+ $newDestination = $destinationTr->account;
+ $this->assertNotEquals($destination->id, $newDestination->id);
+ }
+
+ /**
+ * Test this on a split journal.
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount::act()
+ */
+ public function testSplitJournal()
+ {
+ $transaction = Transaction::orderBy('count', 'DESC')->groupBy('transaction_journal_id')
+ ->get(['transaction_journal_id', DB::raw('COUNT(transaction_journal_id) as count')])
+ ->first();
+ $journal = TransactionJournal::find($transaction->transaction_journal_id);
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new asset ' . rand(1, 1000);
+ $action = new SetDestinationAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetNotesTest.php b/tests/Unit/TransactionRules/Actions/SetNotesTest.php
new file mode 100644
index 0000000000..96e4d8edf5
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetNotesTest.php
@@ -0,0 +1,81 @@
+notes()->first();
+ if (is_null($note)) {
+ $note = new Note;
+ $note->noteable()->associate($journal);
+ }
+ $note->text = 'Hello test note';
+ $note->save();
+ $this->assertEquals(1, $journal->notes()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'These are new notes ' . rand(1, 1234);
+ $action = new SetNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // assert result
+ $this->assertEquals(1, $journal->notes()->count());
+ $this->assertEquals($note->id, $journal->notes()->first()->id);
+
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Actions\SetNotes::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetNotes::act()
+ */
+ public function testActNoNotes()
+ {
+ // give journal a note:
+ $journal = TransactionJournal::find(16);
+ $journal->notes()->forceDelete();
+ $this->assertEquals(0, $journal->notes()->count());
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'These are new notes ' . rand(1, 1234);
+ $action = new SetNotes($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // assert result
+ $this->assertEquals(1, $journal->notes()->count());
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php b/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php
new file mode 100644
index 0000000000..d4ec0912be
--- /dev/null
+++ b/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php
@@ -0,0 +1,173 @@
+first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $sourceTr->account;
+ $user = $journal->user;
+ $accountType = AccountType::whereType(AccountType::REVENUE)->first();
+ $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $source->id)->first();
+ $this->assertNotEquals($source->id, $account->id);
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $account->name;
+ $action = new SetSourceAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $newSource = $sourceTr->account;
+ $this->assertNotEquals($source->id, $newSource->id);
+ $this->assertEquals($newSource->id, $account->id);
+ }
+
+ /**
+ * Give deposit new revenue account.
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::findRevenueAccount
+ */
+ public function testActDepositNewUpdated()
+ {
+ $type = TransactionType::whereType(TransactionType::DEPOSIT)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $sourceTr->account;
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new revenue ' . rand(1, 1000);
+ $action = new SetSourceAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $newSource = $sourceTr->account;
+ $this->assertNotEquals($source->id, $newSource->id);
+ }
+
+ /**
+ * Give withdrawal existing asset account.
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::findAssetAccount()
+ */
+ public function testActWithdrawalExistingUpdated()
+ {
+ $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $sourceTr->account;
+ $user = $journal->user;
+ $accountType = AccountType::whereType(AccountType::ASSET)->first();
+ $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $source->id)->first();
+ $this->assertNotEquals($source->id, $account->id);
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = $account->name;
+ $action = new SetSourceAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertTrue($result);
+
+ // test journal for new account
+ $journal = TransactionJournal::find($journal->id);
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $newSource = $sourceTr->account;
+ $this->assertNotEquals($source->id, $newSource->id);
+ $this->assertEquals($newSource->id, $account->id);
+ }
+
+ /**
+ * Give withdrawal new asset account (will fail)
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::act()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::findAssetAccount()
+ */
+ public function testActWithdrawalNew()
+ {
+ $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ $journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $sourceTr->account;
+
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new asset ' . rand(1, 1000);
+ $action = new SetSourceAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertFalse($result);
+
+ // test journal for still having old account
+ $journal = TransactionJournal::find($journal->id);
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $newSource = $sourceTr->account;
+ $this->assertEquals($source->id, $newSource->id);
+ }
+
+ /**
+ * Test this on a split journal.
+ *
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::__construct()
+ * @covers \FireflyIII\TransactionRules\Actions\SetSourceAccount::act()
+ */
+ public function testSplitJournal()
+ {
+ $transaction = Transaction::orderBy('count', 'DESC')->groupBy('transaction_journal_id')
+ ->get(['transaction_journal_id', DB::raw('COUNT(transaction_journal_id) as count')])
+ ->first();
+ $journal = TransactionJournal::find($transaction->transaction_journal_id);
+ // fire the action:
+ $ruleAction = new RuleAction;
+ $ruleAction->action_value = 'Some new asset ' . rand(1, 1000);
+ $action = new SetSourceAccount($ruleAction);
+ $result = $action->act($journal);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/AmountExactlyTest.php b/tests/Unit/TransactionRules/Triggers/AmountExactlyTest.php
new file mode 100644
index 0000000000..c9d0fcae97
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/AmountExactlyTest.php
@@ -0,0 +1,72 @@
+destination_amount = '12.34';
+ $trigger = AmountExactly::makeFromStrings('12.340', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly::triggered
+ */
+ public function testTriggeredNotExact()
+ {
+ $journal = new TransactionJournal;
+ $journal->destination_amount = '12.35';
+ $trigger = AmountExactly::makeFromStrings('12.340', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = AmountExactly::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = AmountExactly::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/AmountLessTest.php b/tests/Unit/TransactionRules/Triggers/AmountLessTest.php
new file mode 100644
index 0000000000..62e0805c85
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/AmountLessTest.php
@@ -0,0 +1,84 @@
+destination_amount = '12.34';
+ $trigger = AmountLess::makeFromStrings('12.50', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
+ */
+ public function testTriggeredExact()
+ {
+ $journal = new TransactionJournal;
+ $journal->destination_amount = '12.35';
+ $trigger = AmountLess::makeFromStrings('12.35', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
+ */
+ public function testTriggeredNotLess()
+ {
+ $journal = new TransactionJournal;
+ $journal->destination_amount = '12.35';
+ $trigger = AmountLess::makeFromStrings('12.00', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountLess::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = AmountLess::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountLess::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = AmountLess::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/AmountMoreTest.php b/tests/Unit/TransactionRules/Triggers/AmountMoreTest.php
new file mode 100644
index 0000000000..1302e63746
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/AmountMoreTest.php
@@ -0,0 +1,94 @@
+destination_amount = '12.35';
+ $trigger = AmountMore::makeFromStrings('12.35', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::triggered
+ */
+ public function testTriggeredMore()
+ {
+ $journal = new TransactionJournal;
+ $journal->destination_amount = '12.34';
+ $trigger = AmountMore::makeFromStrings('12.10', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::triggered
+ */
+ public function testTriggeredNotMore()
+ {
+ $journal = new TransactionJournal;
+ $journal->destination_amount = '12.35';
+ $trigger = AmountMore::makeFromStrings('12.50', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = '1';
+ $result = AmountMore::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = AmountMore::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::willMatchEverything
+ */
+ public function testWillMatchEverythingZero()
+ {
+ $value = '0';
+ $result = AmountMore::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
new file mode 100644
index 0000000000..59f636edac
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
@@ -0,0 +1,101 @@
+user->budgets()->first();
+ $journal->budgets()->detach();
+ $journal->budgets()->save($budget);
+ $this->assertEquals(1, $journal->budgets()->count());
+
+ $trigger = BudgetIs::makeFromStrings($budget->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\BudgetIs::triggered
+ */
+ public function testTriggeredNotJournal()
+ {
+ $journal = TransactionJournal::find(18);
+ $budget = $journal->user->budgets()->first();
+ $otherBudget = $journal->user->budgets()->where('id', '!=', $budget->id)->first();
+ $journal->budgets()->detach();
+ $journal->budgets()->save($budget);
+ $this->assertEquals(1, $journal->budgets()->count());
+
+
+ $trigger = BudgetIs::makeFromStrings($otherBudget->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\BudgetIs::triggered
+ */
+ public function testTriggeredTransaction()
+ {
+ $journal = TransactionJournal::find(19);
+ $transaction = $journal->transactions()->first();
+ $budget = $journal->user->budgets()->first();
+
+ $journal->budgets()->detach();
+ $transaction->budgets()->save($budget);
+ $this->assertEquals(0, $journal->budgets()->count());
+ $this->assertEquals(1, $transaction->budgets()->count());
+
+
+ $trigger = BudgetIs::makeFromStrings($budget->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\BudgetIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = BudgetIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\BudgetIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = BudgetIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php b/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
new file mode 100644
index 0000000000..1066c5bdd4
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
@@ -0,0 +1,101 @@
+user->categories()->first();
+ $journal->categories()->detach();
+ $journal->categories()->save($category);
+ $this->assertEquals(1, $journal->categories()->count());
+
+ $trigger = CategoryIs::makeFromStrings($category->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\CategoryIs::triggered
+ */
+ public function testTriggeredNotJournal()
+ {
+ $journal = TransactionJournal::find(18);
+ $category = $journal->user->categories()->first();
+ $otherCategory = $journal->user->categories()->where('id', '!=', $category->id)->first();
+ $journal->categories()->detach();
+ $journal->categories()->save($category);
+ $this->assertEquals(1, $journal->categories()->count());
+
+
+ $trigger = CategoryIs::makeFromStrings($otherCategory->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\CategoryIs::triggered
+ */
+ public function testTriggeredTransaction()
+ {
+ $journal = TransactionJournal::find(19);
+ $transaction = $journal->transactions()->first();
+ $category = $journal->user->categories()->first();
+
+ $journal->categories()->detach();
+ $transaction->categories()->save($category);
+ $this->assertEquals(0, $journal->categories()->count());
+ $this->assertEquals(1, $transaction->categories()->count());
+
+
+ $trigger = CategoryIs::makeFromStrings($category->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\CategoryIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = CategoryIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\CategoryIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = CategoryIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/DescriptionContainsTest.php b/tests/Unit/TransactionRules/Triggers/DescriptionContainsTest.php
new file mode 100644
index 0000000000..eadab760e0
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/DescriptionContainsTest.php
@@ -0,0 +1,117 @@
+description = 'Lorem IPSUM bla bla ';
+ $trigger = DescriptionContains::makeFromStrings('ipsum', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Lorem IPSUM bla bla ';
+ $trigger = DescriptionContains::makeFromStrings('blurb', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
+ */
+ public function testTriggeredDefault()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Should contain test string';
+ $trigger = DescriptionContains::makeFromStrings('cont', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
+ */
+ public function testTriggeredEnd()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionContains::makeFromStrings('pen', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
+ */
+ public function testTriggeredStart()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionContains::makeFromStrings('somet', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = DescriptionContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = DescriptionContains::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = DescriptionContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/DescriptionEndsTest.php b/tests/Unit/TransactionRules/Triggers/DescriptionEndsTest.php
new file mode 100644
index 0000000000..6d386ac426
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/DescriptionEndsTest.php
@@ -0,0 +1,129 @@
+description = 'Lorem IPSUMbla';
+ $trigger = DescriptionEnds::makeFromStrings('umbla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Lorem IPSUM blabla';
+ $trigger = DescriptionEnds::makeFromStrings('lorem', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
+ */
+ public function testTriggeredDefault()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Should contain test string';
+ $trigger = DescriptionEnds::makeFromStrings('string', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
+ */
+ public function testTriggeredClose()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionEnds::makeFromStrings('happe', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionEnds::makeFromStrings('xhappen', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
+ */
+ public function testTriggeredLongSearch()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something';
+ $trigger = DescriptionEnds::makeFromStrings('Something is', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = DescriptionEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = DescriptionEnds::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = DescriptionEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/DescriptionIsTest.php b/tests/Unit/TransactionRules/Triggers/DescriptionIsTest.php
new file mode 100644
index 0000000000..457527c3cb
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/DescriptionIsTest.php
@@ -0,0 +1,95 @@
+description = 'Lorem IPSUMbla';
+ $trigger = DescriptionIs::makeFromStrings('lorem ipsumbla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Lorem IPSUM blabla';
+ $trigger = DescriptionIs::makeFromStrings('lorem', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
+ */
+ public function testTriggeredDefault()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Should be test string';
+ $trigger = DescriptionIs::makeFromStrings('Should be test string', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
+ */
+ public function testTriggeredClose()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionIs::makeFromStrings('Something is going to happe', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = DescriptionIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = DescriptionIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/DescriptionStartsTest.php b/tests/Unit/TransactionRules/Triggers/DescriptionStartsTest.php
new file mode 100644
index 0000000000..019fe6c101
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/DescriptionStartsTest.php
@@ -0,0 +1,117 @@
+description = 'Lorem IPSUMbla';
+ $trigger = DescriptionStarts::makeFromStrings('lorem', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Lorem IPSUM blabla';
+ $trigger = DescriptionStarts::makeFromStrings('blabla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
+ */
+ public function testTriggeredDefault()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Should contain test string';
+ $trigger = DescriptionStarts::makeFromStrings('Should', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
+ */
+ public function testTriggeredClose()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something is going to happen';
+ $trigger = DescriptionStarts::makeFromStrings('omething', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
+ */
+ public function testTriggeredLongSearch()
+ {
+ $journal = new TransactionJournal;
+ $journal->description = 'Something';
+ $trigger = DescriptionStarts::makeFromStrings('Something is', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = DescriptionStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = DescriptionStarts::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = DescriptionStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
new file mode 100644
index 0000000000..e09d743071
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
@@ -0,0 +1,84 @@
+transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountContains::makeFromStrings($account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountContains::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(21);
+
+ $trigger = FromAccountContains::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = FromAccountContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = FromAccountContains::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = FromAccountContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
new file mode 100644
index 0000000000..52309cbd4c
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
@@ -0,0 +1,98 @@
+transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountEnds::makeFromStrings(substr($account->name, -3), false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(22);
+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountEnds::makeFromStrings('bla-bla-bla' . $account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(23);
+
+ $trigger = FromAccountEnds::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = FromAccountEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = FromAccountEnds::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = FromAccountEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
new file mode 100644
index 0000000000..af509b07f8
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
@@ -0,0 +1,85 @@
+transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountIs::makeFromStrings($account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(23);
+
+ $trigger = FromAccountIs::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = FromAccountIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = FromAccountIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = FromAccountIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
new file mode 100644
index 0000000000..a5d8fea9c0
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
@@ -0,0 +1,98 @@
+transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountStarts::makeFromStrings(substr($account->name,0, -3), false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(22);
+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = FromAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(23);
+
+ $trigger = FromAccountStarts::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = FromAccountStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = FromAccountStarts::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = FromAccountStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
new file mode 100644
index 0000000000..763e3b5e0c
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
@@ -0,0 +1,88 @@
+user->budgets()->first();
+ $journal->budgets()->detach();
+ $journal->budgets()->save($budget);
+
+ $this->assertEquals(1, $journal->budgets()->count());
+ $trigger = HasAnyBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyBudget::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(24);
+ $journal->budgets()->detach();
+ $this->assertEquals(0, $journal->budgets()->count());
+ $trigger = HasAnyBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyBudget::triggered
+ */
+ public function testTriggeredTransactions()
+ {
+ $journal = TransactionJournal::find(26);
+ $budget = $journal->user->budgets()->first();
+ $journal->budgets()->detach();
+ $this->assertEquals(0, $journal->budgets()->count());
+
+ // append to transaction
+ foreach ($journal->transactions()->get() as $index => $transaction) {
+ $transaction->budgets()->detach();
+ if ($index === 0) {
+ $transaction->budgets()->save($budget);
+ }
+ }
+
+ $trigger = HasAnyBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyBudget::willMatchEverything
+ */
+ public function testWillMatchEverything()
+ {
+ $value = '';
+ $result = HasAnyBudget::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
new file mode 100644
index 0000000000..cb3d4bf5d6
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
@@ -0,0 +1,88 @@
+user->categories()->first();
+ $journal->categories()->detach();
+ $journal->categories()->save($category);
+
+ $this->assertEquals(1, $journal->categories()->count());
+ $trigger = HasAnyCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyCategory::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(24);
+ $journal->categories()->detach();
+ $this->assertEquals(0, $journal->categories()->count());
+ $trigger = HasAnyCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyCategory::triggered
+ */
+ public function testTriggeredTransactions()
+ {
+ $journal = TransactionJournal::find(26);
+ $category = $journal->user->categories()->first();
+ $journal->categories()->detach();
+ $this->assertEquals(0, $journal->categories()->count());
+
+ // append to transaction
+ foreach ($journal->transactions()->get() as $index => $transaction) {
+ $transaction->categories()->detach();
+ if ($index === 0) {
+ $transaction->categories()->save($category);
+ }
+ }
+
+ $trigger = HasAnyCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyCategory::willMatchEverything
+ */
+ public function testWillMatchEverything()
+ {
+ $value = '';
+ $result = HasAnyCategory::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
new file mode 100644
index 0000000000..b2646a32eb
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
@@ -0,0 +1,65 @@
+user->tags()->first();
+ $journal->tags()->detach();
+ $journal->tags()->save($tag);
+
+ $this->assertEquals(1, $journal->tags()->count());
+ $trigger = HasAnyTag::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyTag::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(24);
+ $journal->tags()->detach();
+ $this->assertEquals(0, $journal->tags()->count());
+ $trigger = HasAnyTag::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAnyTag::willMatchEverything
+ */
+ public function testWillMatchEverything()
+ {
+ $value = '';
+ $result = HasAnyTag::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
new file mode 100644
index 0000000000..15b61beb57
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
@@ -0,0 +1,74 @@
+user->attachments()->first();
+ $journal->attachments()->save($attachment);
+ $this->assertEquals(1, $journal->attachments()->count());
+
+ $trigger = HasAttachment::makeFromStrings('1', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAttachment::triggered
+ */
+ public function testTriggeredFalse()
+ {
+ $journal = TransactionJournal::find(27);
+ $this->assertEquals(0, $journal->attachments()->count());
+
+ $trigger = HasAttachment::makeFromStrings('1', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAttachment::willMatchEverything
+ */
+ public function testWillMatchEverything()
+ {
+ $value = '5';
+ $result = HasAttachment::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasAttachment::willMatchEverything
+ */
+ public function testWillMatchEverythingTrue()
+ {
+ $value = -1;
+ $result = HasAttachment::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
new file mode 100644
index 0000000000..edec402c8a
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
@@ -0,0 +1,88 @@
+user->budgets()->first();
+ $journal->budgets()->detach();
+ $journal->budgets()->save($budget);
+ $this->assertEquals(1, $journal->budgets()->count());
+
+ $trigger = HasNoBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoBudget::triggered
+ */
+ public function testTriggeredNoBudget()
+ {
+ $journal = TransactionJournal::find(29);
+ $journal->budgets()->detach();
+ $this->assertEquals(0, $journal->budgets()->count());
+
+
+ $trigger = HasNoBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoBudget::triggered
+ */
+ public function testTriggeredTransaction()
+ {
+ $journal = TransactionJournal::find(30);
+ $transaction = $journal->transactions()->first();
+ $budget = $journal->user->budgets()->first();
+
+ $journal->budgets()->detach();
+ $transaction->budgets()->save($budget);
+ $this->assertEquals(0, $journal->budgets()->count());
+ $this->assertEquals(1, $transaction->budgets()->count());
+
+
+ $trigger = HasNoBudget::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoBudget::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = HasNoBudget::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php b/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
new file mode 100644
index 0000000000..772211af7b
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
@@ -0,0 +1,88 @@
+user->categories()->first();
+ $journal->categories()->detach();
+ $journal->categories()->save($category);
+ $this->assertEquals(1, $journal->categories()->count());
+
+ $trigger = HasNoCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoCategory::triggered
+ */
+ public function testTriggeredNoCategory()
+ {
+ $journal = TransactionJournal::find(32);
+ $journal->categories()->detach();
+ $this->assertEquals(0, $journal->categories()->count());
+
+
+ $trigger = HasNoCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoCategory::triggered
+ */
+ public function testTriggeredTransaction()
+ {
+ $journal = TransactionJournal::find(33);
+ $transaction = $journal->transactions()->first();
+ $category = $journal->user->categories()->first();
+
+ $journal->categories()->detach();
+ $transaction->categories()->save($category);
+ $this->assertEquals(0, $journal->categories()->count());
+ $this->assertEquals(1, $transaction->categories()->count());
+
+
+ $trigger = HasNoCategory::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoCategory::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = HasNoCategory::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php b/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
new file mode 100644
index 0000000000..13a27ec010
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
@@ -0,0 +1,68 @@
+tags()->detach();
+ $this->assertEquals(0, $journal->tags()->count());
+
+
+ $trigger = HasNoTag::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoTag::triggered
+ */
+ public function testTriggeredTag()
+ {
+ $journal = TransactionJournal::find(35);
+ $tag = $journal->user->tags()->first();
+ $journal->tags()->detach();
+ $journal->tags()->save($tag);
+ $this->assertEquals(1, $journal->tags()->count());
+
+ $trigger = HasNoTag::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\HasNoTag::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = HasNoTag::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php b/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
new file mode 100644
index 0000000000..7c726af7c0
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
@@ -0,0 +1,82 @@
+notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Bla bla bla';
+ $note->save();
+ $trigger = NotesAny::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAny::triggered
+ */
+ public function testTriggeredEmpty()
+ {
+ $journal = TransactionJournal::find(37);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = '';
+ $note->save();
+ $trigger = NotesAny::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAny::triggered
+ */
+ public function testTriggeredNone()
+ {
+ $journal = TransactionJournal::find(38);
+ $journal->notes()->delete();
+ $trigger = NotesAny::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAny::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = NotesAny::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesAreTest.php b/tests/Unit/TransactionRules/Triggers/NotesAreTest.php
new file mode 100644
index 0000000000..2951ad655f
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesAreTest.php
@@ -0,0 +1,109 @@
+notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Bla bla bla';
+ $note->save();
+ $trigger = NotesAre::makeFromStrings('Bla bla bla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
+ */
+ public function testTriggeredEmpty()
+ {
+ $journal = TransactionJournal::find(40);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = '';
+ $note->save();
+ $trigger = NotesAre::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
+ */
+ public function testTriggeredDifferent()
+ {
+ $journal = TransactionJournal::find(41);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Some note';
+ $note->save();
+ $trigger = NotesAre::makeFromStrings('Not the note', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
+ */
+ public function testTriggeredNone()
+ {
+ $journal = TransactionJournal::find(42);
+ $journal->notes()->delete();
+ $trigger = NotesAre::makeFromStrings('Bla bla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAre::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = NotesAre::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesAre::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = NotesAre::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesContainTest.php b/tests/Unit/TransactionRules/Triggers/NotesContainTest.php
new file mode 100644
index 0000000000..e1c27a8e01
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesContainTest.php
@@ -0,0 +1,135 @@
+notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Bla bliepbla bla';
+ $note->save();
+ $trigger = NotesContain::makeFromStrings('blIEp', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
+ */
+ public function testTriggeredEmpty()
+ {
+ $journal = TransactionJournal::find(44);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = '';
+ $note->save();
+ $trigger = NotesContain::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
+ */
+ public function testTriggeredPartial()
+ {
+ $journal = TransactionJournal::find(45);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Some note';
+ $note->save();
+ $trigger = NotesContain::makeFromStrings('Some note contains', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
+ */
+ public function testTriggeredDifferent()
+ {
+ $journal = TransactionJournal::find(46);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Some note';
+ $note->save();
+ $trigger = NotesContain::makeFromStrings('82991911', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
+ */
+ public function testTriggeredNone()
+ {
+ $journal = TransactionJournal::find(47);
+ $journal->notes()->delete();
+ $trigger = NotesContain::makeFromStrings('Bla bla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = NotesContain::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = NotesContain::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesContain::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = NotesContain::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php b/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
new file mode 100644
index 0000000000..bff8b571da
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
@@ -0,0 +1,83 @@
+notes()->delete();
+ $trigger = NotesEmpty::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEmpty::triggered
+ */
+ public function testTriggeredEmpty()
+ {
+ $journal = TransactionJournal::find(49);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = '';
+ $note->save();
+ $trigger = NotesEmpty::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEmpty::triggered
+ */
+ public function testTriggeredPartial()
+ {
+ $journal = TransactionJournal::find(50);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Some note';
+ $note->save();
+ $trigger = NotesEmpty::makeFromStrings('', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEmpty::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = NotesEmpty::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesEndTest.php b/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
new file mode 100644
index 0000000000..3283835492
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
@@ -0,0 +1,107 @@
+notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Bla bliepblabla';
+ $note->save();
+ $trigger = NotesEnd::makeFromStrings('blaBla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(53);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'blabla';
+ $note->save();
+ $trigger = NotesEnd::makeFromStrings('Blablabla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
+ */
+ public function testTriggeredNoMatch()
+ {
+ $journal = TransactionJournal::find(52);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'blabla';
+ $note->save();
+ $trigger = NotesEnd::makeFromStrings('12345', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = NotesEnd::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = NotesEnd::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = NotesEnd::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/NotesStartTest.php b/tests/Unit/TransactionRules/Triggers/NotesStartTest.php
new file mode 100644
index 0000000000..bde2e742bc
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/NotesStartTest.php
@@ -0,0 +1,107 @@
+notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'Blabliepblabla';
+ $note->save();
+ $trigger = NotesStart::makeFromStrings('blaBlie', false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesStart::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(55);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'blabla';
+ $note->save();
+ $trigger = NotesStart::makeFromStrings('Blablabla', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesStart::triggered
+ */
+ public function testTriggeredNoMatch()
+ {
+ $journal = TransactionJournal::find(56);
+ $journal->notes()->delete();
+ $note = new Note();
+ $note->noteable()->associate($journal);
+ $note->text = 'blabla';
+ $note->save();
+ $trigger = NotesStart::makeFromStrings('12345', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesStart::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = NotesStart::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesStart::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = NotesStart::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\NotesStart::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = NotesStart::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/TagIsTest.php b/tests/Unit/TransactionRules/Triggers/TagIsTest.php
new file mode 100644
index 0000000000..450cdacc62
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/TagIsTest.php
@@ -0,0 +1,94 @@
+tags()->detach();
+ $tags = $journal->user->tags()->take(3)->get();
+ $search = '';
+ foreach ($tags as $index => $tag) {
+ $journal->tags()->save($tag);
+ if ($index === 1) {
+ $search = $tag->tag;
+ }
+ }
+ $this->assertEquals(3, $journal->tags()->count());
+
+ $trigger = TagIs::makeFromStrings($search, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TagIs::triggered
+ */
+ public function testNotTriggered()
+ {
+ $journal = TransactionJournal::find(58);
+ $journal->tags()->detach();
+ $this->assertEquals(0, $journal->tags()->count());
+
+ $trigger = TagIs::makeFromStrings('SomeTag', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TagIs::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = TagIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TagIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = TagIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TagIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = TagIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
new file mode 100644
index 0000000000..f9d2503722
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
@@ -0,0 +1,82 @@
+transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+ $trigger = ToAccountContains::makeFromStrings($account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountContains::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(60);
+ $trigger = ToAccountContains::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = ToAccountContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = ToAccountContains::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountContains::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = ToAccountContains::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
new file mode 100644
index 0000000000..69880faf75
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
@@ -0,0 +1,98 @@
+transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = ToAccountEnds::makeFromStrings(substr($account->name, -3), false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(62);
+ $transaction = $journal->transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = ToAccountEnds::makeFromStrings('bla-bla-bla' . $account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(63);
+
+ $trigger = ToAccountEnds::makeFromStrings(strval(rand(1, 234)), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = ToAccountEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = ToAccountEnds::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = ToAccountEnds::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
new file mode 100644
index 0000000000..a2ed1e22c3
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
@@ -0,0 +1,85 @@
+transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = ToAccountIs::makeFromStrings($account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(65);
+
+ $trigger = ToAccountIs::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = ToAccountIs::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = ToAccountIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = ToAccountIs::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
new file mode 100644
index 0000000000..b5b5560c35
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
@@ -0,0 +1,98 @@
+transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = ToAccountStarts::makeFromStrings(substr($account->name,0, -3), false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::triggered
+ */
+ public function testTriggeredLonger()
+ {
+ $journal = TransactionJournal::find(67);
+ $transaction = $journal->transactions()->where('amount', '>', 0)->first();
+ $account = $transaction->account;
+
+ $trigger = ToAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::triggered
+ */
+ public function testTriggeredNot()
+ {
+ $journal = TransactionJournal::find(68);
+
+ $trigger = ToAccountStarts::makeFromStrings('some name' . rand(1, 234), false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingEmpty()
+ {
+ $value = '';
+ $result = ToAccountStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = ToAccountStarts::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = ToAccountStarts::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php b/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
new file mode 100644
index 0000000000..faca9c91f5
--- /dev/null
+++ b/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
@@ -0,0 +1,70 @@
+transactionType->type;
+ $trigger = TransactionType::makeFromStrings($type, false);
+ $result = $trigger->triggered($journal);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TransactionType::triggered
+ */
+ public function testTriggeredFalse()
+ {
+ $journal = TransactionJournal::find(70);
+ $trigger = TransactionType::makeFromStrings('NonExisting', false);
+ $result = $trigger->triggered($journal);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TransactionType::willMatchEverything
+ */
+ public function testWillMatchEverythingNotNull()
+ {
+ $value = 'x';
+ $result = TransactionType::willMatchEverything($value);
+ $this->assertFalse($result);
+ }
+
+ /**
+ * @covers \FireflyIII\TransactionRules\Triggers\TransactionType::willMatchEverything
+ */
+ public function testWillMatchEverythingNull()
+ {
+ $value = null;
+ $result = TransactionType::willMatchEverything($value);
+ $this->assertTrue($result);
+ }
+
+
+}
\ No newline at end of file