mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
New tests.
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user