mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
New tests.
This commit is contained in:
72
tests/Unit/TransactionRules/Triggers/AmountExactlyTest.php
Normal file
72
tests/Unit/TransactionRules/Triggers/AmountExactlyTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* AmountExactlyTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\AmountExactly;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AmountExactlyTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class AmountExactlyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountExactly::triggered
|
||||
*/
|
||||
public function testTriggeredExact()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
84
tests/Unit/TransactionRules/Triggers/AmountLessTest.php
Normal file
84
tests/Unit/TransactionRules/Triggers/AmountLessTest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* AmountLessTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\AmountLess;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AmountLessTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class AmountLessTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
|
||||
*/
|
||||
public function testTriggeredLess()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
94
tests/Unit/TransactionRules/Triggers/AmountMoreTest.php
Normal file
94
tests/Unit/TransactionRules/Triggers/AmountMoreTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* AmountMoreTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\AmountMore;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AmountMoreTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class AmountMoreTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountMore::triggered
|
||||
*/
|
||||
public function testTriggeredExact()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
101
tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
Normal file
101
tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* BudgetIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\BudgetIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class BudgetIsTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class BudgetIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\BudgetIs::triggered
|
||||
*/
|
||||
public function testTriggeredJournal()
|
||||
{
|
||||
$journal = TransactionJournal::find(17);
|
||||
$budget = $journal->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);
|
||||
}
|
||||
}
|
101
tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
Normal file
101
tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* CategoryIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\CategoryIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class CategoryIsTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class CategoryIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\CategoryIs::triggered
|
||||
*/
|
||||
public function testTriggeredJournal()
|
||||
{
|
||||
$journal = TransactionJournal::find(17);
|
||||
$category = $journal->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);
|
||||
}
|
||||
}
|
117
tests/Unit/TransactionRules/Triggers/DescriptionContainsTest.php
Normal file
117
tests/Unit/TransactionRules/Triggers/DescriptionContainsTest.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* DescriptionContains.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\DescriptionContains;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DescriptionContains
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class DescriptionContainsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
|
||||
*/
|
||||
public function testTriggeredCase()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
}
|
129
tests/Unit/TransactionRules/Triggers/DescriptionEndsTest.php
Normal file
129
tests/Unit/TransactionRules/Triggers/DescriptionEndsTest.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* DescriptionEndsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\DescriptionEnds;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DescriptionEnds
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class DescriptionEndsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
|
||||
*/
|
||||
public function testTriggeredCase()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
}
|
95
tests/Unit/TransactionRules/Triggers/DescriptionIsTest.php
Normal file
95
tests/Unit/TransactionRules/Triggers/DescriptionIsTest.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* DescriptionIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\DescriptionIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DescriptionIs
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class DescriptionIsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
|
||||
*/
|
||||
public function testTriggeredCase()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
}
|
117
tests/Unit/TransactionRules/Triggers/DescriptionStartsTest.php
Normal file
117
tests/Unit/TransactionRules/Triggers/DescriptionStartsTest.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* DescriptionStartsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\DescriptionStarts;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DescriptionStarts
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class DescriptionStartsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
|
||||
*/
|
||||
public function testTriggeredCase()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* FromAccountContainsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class FromAccountContainsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class FromAccountContainsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountContains::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(20);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
98
tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
Normal file
98
tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* FromAccountEndsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class FromAccountEndsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class FromAccountEndsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountEnds::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(22);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
85
tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
Normal file
85
tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* FromAccountIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class FromAccountIsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class FromAccountIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(22);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* FromAccountStartsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class FromAccountStartsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class FromAccountStartsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountStarts::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(22);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
88
tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
Normal file
88
tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* HasAnyBudgetTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAnyBudget;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasAnyBudgetTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasAnyBudgetTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasAnyBudget::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(25);
|
||||
$budget = $journal->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);
|
||||
}
|
||||
|
||||
}
|
88
tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
Normal file
88
tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* HasAnyCategoryTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAnyCategory;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasAnyCategoryTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasAnyCategoryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasAnyCategory::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(25);
|
||||
$category = $journal->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);
|
||||
}
|
||||
|
||||
}
|
65
tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
Normal file
65
tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* HasAnyTagTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAnyTag;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasAnyTagTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasAnyTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasAnyTag::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(25);
|
||||
$tag = $journal->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);
|
||||
}
|
||||
|
||||
}
|
74
tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
Normal file
74
tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* HasAttachment.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAttachment;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasAttachmentTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasAttachmentTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasAttachment::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(26);
|
||||
$attachment = $journal->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);
|
||||
}
|
||||
|
||||
}
|
88
tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
Normal file
88
tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* HasNoBudgetTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasNoBudget;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasNoBudgetTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasNoBudgetTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasNoBudget::triggered
|
||||
*/
|
||||
public function testTriggeredBudget()
|
||||
{
|
||||
$journal = TransactionJournal::find(28);
|
||||
$budget = $journal->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);
|
||||
}
|
||||
}
|
88
tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
Normal file
88
tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* HasNoCategoryTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasNoCategory;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasNoCategoryTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasNoCategoryTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasNoCategory::triggered
|
||||
*/
|
||||
public function testTriggeredCategory()
|
||||
{
|
||||
$journal = TransactionJournal::find(31);
|
||||
$category = $journal->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);
|
||||
}
|
||||
}
|
68
tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
Normal file
68
tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* HasNoTagTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasNoTag;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class HasNoTagTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class HasNoTagTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\HasNoTag::triggered
|
||||
*/
|
||||
public function testTriggeredNoTag()
|
||||
{
|
||||
$journal = TransactionJournal::find(34);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
82
tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
Normal file
82
tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesAnyTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesAny;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesAnyTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesAnyTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAny::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(36);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
109
tests/Unit/TransactionRules/Triggers/NotesAreTest.php
Normal file
109
tests/Unit/TransactionRules/Triggers/NotesAreTest.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesAreTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesAre;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesAreTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesAreTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(39);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
135
tests/Unit/TransactionRules/Triggers/NotesContainTest.php
Normal file
135
tests/Unit/TransactionRules/Triggers/NotesContainTest.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesContainTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesContain;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesContainTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesContainTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(43);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
83
tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
Normal file
83
tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesEmptyTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesEmpty;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesEmptyTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesEmptyTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesEmpty::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(48);
|
||||
$journal->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);
|
||||
}
|
||||
|
||||
}
|
107
tests/Unit/TransactionRules/Triggers/NotesEndTest.php
Normal file
107
tests/Unit/TransactionRules/Triggers/NotesEndTest.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesEndTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesEnd;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesEndTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesEndTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(51);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
107
tests/Unit/TransactionRules/Triggers/NotesStartTest.php
Normal file
107
tests/Unit/TransactionRules/Triggers/NotesStartTest.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* NotesStartTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\NotesStart;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class NotesStartTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class NotesStartTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesStart::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(54);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
94
tests/Unit/TransactionRules/Triggers/TagIsTest.php
Normal file
94
tests/Unit/TransactionRules/Triggers/TagIsTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* TagIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\TagIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class TagIsTest
|
||||
*
|
||||
* @package Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class TagIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TagIs::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(57);
|
||||
$journal->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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* ToAccountContainsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountContains;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ToAccountContainsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class ToAccountContainsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountContains::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(59);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
98
tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
Normal file
98
tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* ToAccountEndsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ToAccountEndsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class ToAccountEndsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountEnds::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(61);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
85
tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
Normal file
85
tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* ToAccountIsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ToAccountIsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class ToAccountIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(64);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
98
tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
Normal file
98
tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* ToAccountStartsTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ToAccountStartsTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class ToAccountStartsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountStarts::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(66);
|
||||
$transaction = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
70
tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
Normal file
70
tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionTypeTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\TransactionType;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class TransactionTypeTest
|
||||
*
|
||||
* @package Tests\Unit\TransactionRules\Triggers
|
||||
*/
|
||||
class TransactionTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TransactionType::triggered
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(69);
|
||||
$type = $journal->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);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user