. */ declare(strict_types=1); namespace Tests\Unit\TransactionRules\Triggers; use FireflyIII\Models\TransactionJournal; use FireflyIII\TransactionRules\Triggers\FromAccountContains; use Tests\TestCase; /** * Class FromAccountContainsTest */ 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); } }