. */ declare(strict_types=1); namespace Tests\Unit\TransactionRules\Triggers; use FireflyIII\Models\TransactionJournal; use FireflyIII\TransactionRules\Triggers\DescriptionIs; use Tests\TestCase; /** * Class DescriptionIs * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class DescriptionIsTest extends TestCase { /** * Set up test */ public function setUp(): void { self::markTestIncomplete('Incomplete for refactor.'); return; } /** * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs */ public function testTriggeredCase(): void { $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 */ public function testTriggeredClose(): void { $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 */ public function testTriggeredDefault(): void { $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 */ public function testTriggeredNot(): void { $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 */ public function testWillMatchEverythingNotNull(): void { $value = 'x'; $result = DescriptionIs::willMatchEverything($value); $this->assertFalse($result); } /** * @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs */ public function testWillMatchEverythingNull(): void { $value = null; $result = DescriptionIs::willMatchEverything($value); $this->assertTrue($result); } }