firefly-iii/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
2017-10-06 15:41:21 +02:00

107 lines
2.9 KiB
PHP

<?php
/**
* NotesEndTest.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\Note;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\TransactionRules\Triggers\NotesEnd;
use Tests\TestCase;
/**
* Class NotesEndTest
*
* @package Unit\TransactionRules\Triggers
*/
class NotesEndTest extends TestCase
{
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
*/
public function testTriggered()
{
$journal = TransactionJournal::find(51);
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
$note->text = 'Bla bliepblabla';
$note->save();
$trigger = NotesEnd::makeFromStrings('blaBla', false);
$result = $trigger->triggered($journal);
$this->assertTrue($result);
}
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
*/
public function testTriggeredLonger()
{
$journal = TransactionJournal::find(53);
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
$note->text = 'blabla';
$note->save();
$trigger = NotesEnd::makeFromStrings('Blablabla', false);
$result = $trigger->triggered($journal);
$this->assertFalse($result);
}
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::triggered
*/
public function testTriggeredNoMatch()
{
$journal = TransactionJournal::find(52);
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
$note->text = 'blabla';
$note->save();
$trigger = NotesEnd::makeFromStrings('12345', false);
$result = $trigger->triggered($journal);
$this->assertFalse($result);
}
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
*/
public function testWillMatchEverythingEmpty()
{
$value = '';
$result = NotesEnd::willMatchEverything($value);
$this->assertTrue($result);
}
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
*/
public function testWillMatchEverythingNotNull()
{
$value = 'x';
$result = NotesEnd::willMatchEverything($value);
$this->assertFalse($result);
}
/**
* @covers \FireflyIII\TransactionRules\Triggers\NotesEnd::willMatchEverything
*/
public function testWillMatchEverythingNull()
{
$value = null;
$result = NotesEnd::willMatchEverything($value);
$this->assertTrue($result);
}
}