mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Added all the old test things.
This commit is contained in:
40
tests/unit/AccountTest.php
Normal file
40
tests/unit/AccountTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class AccountTest
|
||||
*/
|
||||
class AccountTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
// tests
|
||||
|
||||
public function testAccountMeta()
|
||||
{
|
||||
$account = f::create('Account');
|
||||
$newMeta = $account->updateMeta('field', 'value');
|
||||
$this->assertInstanceOf('AccountMeta', $newMeta);
|
||||
$secondMeta = $account->updateMeta('field', 'newValue');
|
||||
$this->assertEquals($newMeta->id, $secondMeta->id);
|
||||
$this->assertEquals($newMeta->data, 'value');
|
||||
$this->assertEquals($secondMeta->data, 'newValue');
|
||||
}
|
||||
|
||||
public function testAccountUser()
|
||||
{
|
||||
$account = f::create('Account');
|
||||
$this->assertInstanceOf('Account', $account);
|
||||
$this->assertInstanceOf('User', $account->user);
|
||||
}
|
||||
|
||||
}
|
||||
27
tests/unit/AccountTypeTest.php
Normal file
27
tests/unit/AccountTypeTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class AccountTypeTest
|
||||
*/
|
||||
class AccountTypeTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
// tests
|
||||
public function testAccounts()
|
||||
{
|
||||
$account = f::create('Account');
|
||||
$this->assertCount(1, $account->accountType()->first()->accounts()->get());
|
||||
}
|
||||
|
||||
}
|
||||
26
tests/unit/BudgetTest.php
Normal file
26
tests/unit/BudgetTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class BudgetTest
|
||||
*/
|
||||
class BudgetTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testUser()
|
||||
{
|
||||
$budget = f::create('Budget');
|
||||
$this->assertInstanceOf('User', $budget->user);
|
||||
|
||||
}
|
||||
}
|
||||
29
tests/unit/PiggyBankRepetitionTest.php
Normal file
29
tests/unit/PiggyBankRepetitionTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class PiggyBankRepetitionTest
|
||||
*/
|
||||
class PiggyBankRepetitionTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testPiggyBankRepetitionScope()
|
||||
{
|
||||
$repetition = f::create('PiggyBankRepetition');
|
||||
$start = clone $repetition->startdate;
|
||||
$target = clone $repetition->targetdate;
|
||||
|
||||
$this->assertCount(1, PiggyBankRepetition::starts($start)->get());
|
||||
$this->assertCount(1, PiggyBankRepetition::targets($target)->get());
|
||||
}
|
||||
}
|
||||
27
tests/unit/PiggyBankTest.php
Normal file
27
tests/unit/PiggyBankTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class PiggyBankTest
|
||||
*/
|
||||
class PiggyBankTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testPiggyBankReminders()
|
||||
{
|
||||
$reminder = f::create('Reminder');
|
||||
$piggyBank = f::create('PiggyBank');
|
||||
$piggyBank->reminders()->save($reminder);
|
||||
$this->assertCount(1, $piggyBank->reminders()->get());
|
||||
}
|
||||
}
|
||||
38
tests/unit/ReminderTest.php
Normal file
38
tests/unit/ReminderTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class ReminderTest
|
||||
*/
|
||||
class ReminderTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testDateIs()
|
||||
{
|
||||
$reminder = f::create('Reminder');
|
||||
$start = clone $reminder->startdate;
|
||||
$end = clone $reminder->enddate;
|
||||
$this->assertCount(1, Reminder::dateIs($start, $end)->get());
|
||||
|
||||
}
|
||||
|
||||
public function testUser()
|
||||
{
|
||||
$user = f::create('User');
|
||||
$reminder = f::create('Reminder');
|
||||
$reminder->user_id = $user->id;
|
||||
$reminder->save();
|
||||
|
||||
$this->assertEquals($reminder->user->id, $user->id);
|
||||
}
|
||||
}
|
||||
25
tests/unit/TransactionGroupTest.php
Normal file
25
tests/unit/TransactionGroupTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class TransactionGroupTest
|
||||
*/
|
||||
class TransactionGroupTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testUser()
|
||||
{
|
||||
$group = f::create('TransactionGroup');
|
||||
$this->assertEquals($group->user_id, $group->user->id);
|
||||
}
|
||||
}
|
||||
33
tests/unit/TransactionJournalTest.php
Normal file
33
tests/unit/TransactionJournalTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalTest
|
||||
*/
|
||||
class TransactionJournalTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testMorethan()
|
||||
{
|
||||
$journal = f::create('TransactionJournal');
|
||||
$transaction = f::create('Transaction');
|
||||
$other = clone $transaction;
|
||||
$journal->transactions()->save($transaction);
|
||||
$journal->transactions()->save($other);
|
||||
|
||||
$amount = floatval($transaction->amount);
|
||||
$amount--;
|
||||
|
||||
$this->assertCount(1, TransactionJournal::moreThan($amount)->get());
|
||||
}
|
||||
}
|
||||
67
tests/unit/TransactionTest.php
Normal file
67
tests/unit/TransactionTest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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::lessThan($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());
|
||||
}
|
||||
}
|
||||
30
tests/unit/TransactionTypeTest.php
Normal file
30
tests/unit/TransactionTypeTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class TransactionTypeTest
|
||||
*/
|
||||
class TransactionTypeTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
// tests
|
||||
|
||||
public function testJournals()
|
||||
{
|
||||
$journal = f::create('TransactionJournal');
|
||||
$type = $journal->transactionType;
|
||||
$this->assertCount(1, $type->transactionJournals()->get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
36
tests/unit/UserTest.php
Normal file
36
tests/unit/UserTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as f;
|
||||
|
||||
/**
|
||||
* Class AccountTest
|
||||
*/
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
// tests
|
||||
|
||||
public function testPreference()
|
||||
{
|
||||
$pref = f::create('Preference');
|
||||
$this->assertEquals($pref->user_id, $pref->user->id);
|
||||
$this->assertCount(1, $pref->user->preferences()->get());
|
||||
}
|
||||
|
||||
public function testReminder()
|
||||
{
|
||||
$reminder = f::create('Reminder');
|
||||
$this->assertEquals($reminder->user_id, $reminder->user->id);
|
||||
$this->assertCount(1, $reminder->user->reminders()->get());
|
||||
}
|
||||
|
||||
}
|
||||
2
tests/unit/_bootstrap.php
Normal file
2
tests/unit/_bootstrap.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
Reference in New Issue
Block a user