. */ declare(strict_types=1); namespace Tests\Unit\TransactionRules\Triggers; use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\TransactionRules\Triggers\AmountExactly; use Tests\TestCase; /** * Class AmountExactlyTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class AmountExactlyTest extends TestCase { /** * Set up test */ public function setUp(): void { self::markTestIncomplete('Incomplete for refactor.'); return; } /** * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly */ public function testTriggeredExact(): void { $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('setUser'); $journalRepos->shouldReceive('getJournalTotal')->andReturn('12.34'); $journal = new TransactionJournal; $journal->user = $this->user(); $journal->destination_amount = '12.34'; $trigger = AmountExactly::makeFromStrings('12.340', false); $result = $trigger->triggered($journal); $this->assertTrue($result); } /** * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly */ public function testTriggeredNotExact(): void { $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('setUser'); $journalRepos->shouldReceive('getJournalTotal')->andReturn('12.34'); $journal = new TransactionJournal; $journal->user = $this->user(); $journal->destination_amount = '12.35'; $trigger = AmountExactly::makeFromStrings('12.340', false); $result = $trigger->triggered($journal); $this->assertFalse($result); } /** * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly */ public function testWillMatchEverythingNotNull(): void { $value = 'x'; $result = AmountExactly::willMatchEverything($value); $this->assertFalse($result); } /** * @covers \FireflyIII\TransactionRules\Triggers\AmountExactly */ public function testWillMatchEverythingNull(): void { $value = null; $result = AmountExactly::willMatchEverything($value); $this->assertTrue($result); } }