. */ declare(strict_types=1); namespace Tests\Unit\TransactionRules\Triggers; use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\TransactionRules\Triggers\AmountMore; use Tests\TestCase; /** * Class AmountMoreTest */ class AmountMoreTest extends TestCase { /** * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::triggered */ public function testTriggeredExact() { $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('setUser'); $journalRepos->shouldReceive('getJournalTotal')->andReturn('12.35'); $journal = new TransactionJournal; $journal->user = $this->user(); $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() { $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 = AmountMore::makeFromStrings('12.10', false); $result = $trigger->triggered($journal); $this->assertTrue($result); } /** * @covers \FireflyIII\TransactionRules\Triggers\AmountMore::triggered */ public function testTriggeredNotMore() { $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('setUser'); $journalRepos->shouldReceive('getJournalTotal')->andReturn('12.35'); $journal = new TransactionJournal; $journal->user = $this->user(); $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); } }