mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 16:40:10 +00:00
Code clean up.
This commit is contained in:
@@ -35,18 +35,6 @@ use Tests\TestCase;
|
||||
*/
|
||||
class AmountLessTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
|
||||
*/
|
||||
public function testTriggeredLess()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->destination_amount = '12.34';
|
||||
$trigger = AmountLess::makeFromStrings('12.50', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
|
||||
*/
|
||||
@@ -59,6 +47,18 @@ class AmountLessTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
|
||||
*/
|
||||
public function testTriggeredLess()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->destination_amount = '12.34';
|
||||
$trigger = AmountLess::makeFromStrings('12.50', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\AmountLess::triggered
|
||||
*/
|
||||
|
||||
@@ -47,19 +47,6 @@ class DescriptionContainsTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
|
||||
*/
|
||||
public function testTriggeredNot()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Lorem IPSUM bla bla ';
|
||||
$trigger = DescriptionContains::makeFromStrings('blurb', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
|
||||
*/
|
||||
@@ -84,6 +71,18 @@ class DescriptionContainsTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
|
||||
*/
|
||||
public function testTriggeredNot()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Lorem IPSUM bla bla ';
|
||||
$trigger = DescriptionContains::makeFromStrings('blurb', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionContains::triggered
|
||||
*/
|
||||
|
||||
@@ -50,16 +50,15 @@ class DescriptionEndsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
|
||||
*/
|
||||
public function testTriggeredNot()
|
||||
public function testTriggeredClose()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionEnds::makeFromStrings('lorem', false);
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionEnds::makeFromStrings('happe', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
|
||||
*/
|
||||
@@ -75,11 +74,11 @@ class DescriptionEndsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
|
||||
*/
|
||||
public function testTriggeredClose()
|
||||
public function testTriggeredLongSearch()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionEnds::makeFromStrings('happe', false);
|
||||
$journal->description = 'Something';
|
||||
$trigger = DescriptionEnds::makeFromStrings('Something is', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
@@ -99,11 +98,11 @@ class DescriptionEndsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionEnds::triggered
|
||||
*/
|
||||
public function testTriggeredLongSearch()
|
||||
public function testTriggeredNot()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Something';
|
||||
$trigger = DescriptionEnds::makeFromStrings('Something is', false);
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionEnds::makeFromStrings('lorem', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -50,16 +50,15 @@ class DescriptionIsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
|
||||
*/
|
||||
public function testTriggeredNot()
|
||||
public function testTriggeredClose()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionIs::makeFromStrings('lorem', false);
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionIs::makeFromStrings('Something is going to happe', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
|
||||
*/
|
||||
@@ -75,11 +74,11 @@ class DescriptionIsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionIs::triggered
|
||||
*/
|
||||
public function testTriggeredClose()
|
||||
public function testTriggeredNot()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionIs::makeFromStrings('Something is going to happe', false);
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionIs::makeFromStrings('lorem', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -50,16 +50,15 @@ class DescriptionStartsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
|
||||
*/
|
||||
public function testTriggeredNot()
|
||||
public function testTriggeredClose()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionStarts::makeFromStrings('blabla', false);
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionStarts::makeFromStrings('omething', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
|
||||
*/
|
||||
@@ -75,11 +74,11 @@ class DescriptionStartsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
|
||||
*/
|
||||
public function testTriggeredClose()
|
||||
public function testTriggeredLongSearch()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Something is going to happen';
|
||||
$trigger = DescriptionStarts::makeFromStrings('omething', false);
|
||||
$journal->description = 'Something';
|
||||
$trigger = DescriptionStarts::makeFromStrings('Something is', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
@@ -87,11 +86,11 @@ class DescriptionStartsTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\DescriptionStarts::triggered
|
||||
*/
|
||||
public function testTriggeredLongSearch()
|
||||
public function testTriggeredNot()
|
||||
{
|
||||
$journal = new TransactionJournal;
|
||||
$journal->description = 'Something';
|
||||
$trigger = DescriptionStarts::makeFromStrings('Something is', false);
|
||||
$journal->description = 'Lorem IPSUM blabla';
|
||||
$trigger = DescriptionStarts::makeFromStrings('blabla', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,16 @@ class FromAccountIsTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty()
|
||||
{
|
||||
$value = '';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
|
||||
*/
|
||||
@@ -82,15 +92,4 @@ class FromAccountIsTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\FromAccountIs::willMatchEverything
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty()
|
||||
{
|
||||
$value = '';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class FromAccountStartsTest extends TestCase
|
||||
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$account = $transaction->account;
|
||||
|
||||
$trigger = FromAccountStarts::makeFromStrings(substr($account->name,0, -3), false);
|
||||
$trigger = FromAccountStarts::makeFromStrings(substr($account->name, 0, -3), false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ class HasAnyTagTest extends TestCase
|
||||
*/
|
||||
public function testTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(25);
|
||||
$tag = $journal->user->tags()->first();
|
||||
$journal = TransactionJournal::find(25);
|
||||
$tag = $journal->user->tags()->first();
|
||||
$journal->tags()->detach();
|
||||
$journal->tags()->save($tag);
|
||||
|
||||
|
||||
@@ -53,22 +53,6 @@ class NotesAreTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
|
||||
*/
|
||||
public function testTriggeredEmpty()
|
||||
{
|
||||
$journal = TransactionJournal::find(40);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = '';
|
||||
$note->save();
|
||||
$trigger = NotesAre::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
|
||||
*/
|
||||
@@ -85,6 +69,22 @@ class NotesAreTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
|
||||
*/
|
||||
public function testTriggeredEmpty()
|
||||
{
|
||||
$journal = TransactionJournal::find(40);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = '';
|
||||
$note->save();
|
||||
$trigger = NotesAre::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesAre::triggered
|
||||
*/
|
||||
|
||||
@@ -53,38 +53,6 @@ class NotesContainTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
public function testTriggeredEmpty()
|
||||
{
|
||||
$journal = TransactionJournal::find(44);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = '';
|
||||
$note->save();
|
||||
$trigger = NotesContain::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
public function testTriggeredPartial()
|
||||
{
|
||||
$journal = TransactionJournal::find(45);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = 'Some note';
|
||||
$note->save();
|
||||
$trigger = NotesContain::makeFromStrings('Some note contains', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
@@ -101,6 +69,22 @@ class NotesContainTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
public function testTriggeredEmpty()
|
||||
{
|
||||
$journal = TransactionJournal::find(44);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = '';
|
||||
$note->save();
|
||||
$trigger = NotesContain::makeFromStrings('', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
@@ -113,6 +97,22 @@ class NotesContainTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::triggered
|
||||
*/
|
||||
public function testTriggeredPartial()
|
||||
{
|
||||
$journal = TransactionJournal::find(45);
|
||||
$journal->notes()->delete();
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($journal);
|
||||
$note->text = 'Some note';
|
||||
$note->save();
|
||||
$trigger = NotesContain::makeFromStrings('Some note contains', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\NotesContain::willMatchEverything
|
||||
*/
|
||||
|
||||
@@ -36,6 +36,20 @@ use Tests\TestCase;
|
||||
class TagIsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TagIs::triggered
|
||||
*/
|
||||
public function testNotTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(58);
|
||||
$journal->tags()->detach();
|
||||
$this->assertEquals(0, $journal->tags()->count());
|
||||
|
||||
$trigger = TagIs::makeFromStrings('SomeTag', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TagIs::triggered
|
||||
*/
|
||||
@@ -58,20 +72,6 @@ class TagIsTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TagIs::triggered
|
||||
*/
|
||||
public function testNotTriggered()
|
||||
{
|
||||
$journal = TransactionJournal::find(58);
|
||||
$journal->tags()->detach();
|
||||
$this->assertEquals(0, $journal->tags()->count());
|
||||
|
||||
$trigger = TagIs::makeFromStrings('SomeTag', false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\TagIs::willMatchEverything
|
||||
*/
|
||||
|
||||
@@ -62,16 +62,6 @@ class ToAccountIsTest extends TestCase
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull()
|
||||
{
|
||||
$value = 'x';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
|
||||
*/
|
||||
@@ -82,6 +72,16 @@ class ToAccountIsTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull()
|
||||
{
|
||||
$value = 'x';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\TransactionRules\Triggers\ToAccountIs::willMatchEverything
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@ class ToAccountStartsTest extends TestCase
|
||||
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $transaction->account;
|
||||
|
||||
$trigger = ToAccountStarts::makeFromStrings(substr($account->name,0, -3), false);
|
||||
$trigger = ToAccountStarts::makeFromStrings(substr($account->name, 0, -3), false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user