mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 03:56:42 +00:00
84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
![]() |
<?php
|
||
|
/**
|
||
|
* FromAccountContainsTest.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\FromAccountContains;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
/**
|
||
|
* Class FromAccountContainsTest
|
||
|
*
|
||
|
* @package Tests\Unit\TransactionRules\Triggers
|
||
|
*/
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|