mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 00:20:03 +00:00
Even more tests!
This commit is contained in:
68
tests/unit/TransactionTest.php
Normal file
68
tests/unit/TransactionTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class TransactionTest
|
||||
*/
|
||||
class TransactionTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAccount()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
|
||||
$this->assertCount(1, Transaction::accountIs($transaction->account)->get());
|
||||
}
|
||||
|
||||
public function testDateAfter()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
$date = clone $transaction->transactionJournal->date;
|
||||
$date->subDay();
|
||||
|
||||
$this->assertCount(1, Transaction::after($date)->get());
|
||||
}
|
||||
|
||||
public function testDateBefore()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
$date = clone $transaction->transactionJournal->date;
|
||||
$date->addDay();
|
||||
|
||||
$this->assertCount(1, Transaction::before($date)->get());
|
||||
}
|
||||
|
||||
public function testLessThan()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
$amount = floatval($transaction->amount);
|
||||
$amount--;
|
||||
$this->assertCount(1, Transaction::moreThan($amount)->get());
|
||||
}
|
||||
|
||||
public function testMoreThan()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
$amount = floatval($transaction->amount);
|
||||
$amount++;
|
||||
|
||||
$this->assertCount(1, Transaction::moreThan($amount)->get());
|
||||
}
|
||||
|
||||
public function testTransactionTypes()
|
||||
{
|
||||
$transaction = f::create('Transaction');
|
||||
$type = $transaction->transactionJournal->transactionType->type;
|
||||
$this->assertCount(1, Transaction::transactionTypes([$type])->get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user