mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Some new tests.
This commit is contained in:
@@ -271,6 +271,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$pct = $pct > 100 ? 100 : $pct;
|
$pct = $pct > 100 ? 100 : $pct;
|
||||||
$account->difference = $diff;
|
$account->difference = $diff;
|
||||||
$account->percentage = round($pct);
|
$account->percentage = round($pct);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountMeta;
|
use FireflyIII\Models\AccountMeta;
|
||||||
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\PiggyBankRepetition;
|
use FireflyIII\Models\PiggyBankRepetition;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
@@ -363,7 +364,6 @@ class AccountRepositoryTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Account\AccountRepository::getPiggyBankAccounts
|
* @covers FireflyIII\Repositories\Account\AccountRepository::getPiggyBankAccounts
|
||||||
* @todo Implement testGetPiggyBankAccounts().
|
|
||||||
*/
|
*/
|
||||||
public function testGetPiggyBankAccounts()
|
public function testGetPiggyBankAccounts()
|
||||||
{
|
{
|
||||||
@@ -377,7 +377,7 @@ class AccountRepositoryTest extends TestCase
|
|||||||
/*
|
/*
|
||||||
* Update id's to match each other:
|
* Update id's to match each other:
|
||||||
*/
|
*/
|
||||||
$piggyBankRepetition->currentamount = rand(1,100);
|
$piggyBankRepetition->currentamount = rand(1, 100);
|
||||||
$piggyBankRepetition->startdate = $date;
|
$piggyBankRepetition->startdate = $date;
|
||||||
$piggyBankRepetition->targetdate = $date;
|
$piggyBankRepetition->targetdate = $date;
|
||||||
$piggyBank->account_id = $account->id;
|
$piggyBank->account_id = $account->id;
|
||||||
@@ -404,12 +404,60 @@ class AccountRepositoryTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts
|
* @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts
|
||||||
* @todo Implement testGetSavingsAccounts().
|
|
||||||
*/
|
*/
|
||||||
public function testGetSavingsAccounts()
|
public function testGetSavingsAccounts()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
// create three accounts:
|
||||||
$this->markTestIncomplete('This test has not been implemented yet.');
|
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
$type = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$account1->account_type_id = $type->id;
|
||||||
|
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$account2->account_type_id = $type->id;
|
||||||
|
$account3 = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$account3->account_type_id = $type->id;
|
||||||
|
|
||||||
|
// make them savings accounts:
|
||||||
|
$meta = new AccountMeta;
|
||||||
|
$meta->name = 'accountRole';
|
||||||
|
$meta->data = 'savingAsset';
|
||||||
|
$meta->account_id = $account1->id;
|
||||||
|
$meta->save();
|
||||||
|
|
||||||
|
$meta = new AccountMeta;
|
||||||
|
$meta->name = 'accountRole';
|
||||||
|
$meta->data = 'savingAsset';
|
||||||
|
$meta->account_id = $account2->id;
|
||||||
|
$meta->save();
|
||||||
|
|
||||||
|
$meta = new AccountMeta;
|
||||||
|
$meta->name = 'accountRole';
|
||||||
|
$meta->data = 'savingAsset';
|
||||||
|
$meta->account_id = $account3->id;
|
||||||
|
$meta->save();
|
||||||
|
|
||||||
|
// assign to the same user:
|
||||||
|
$account2->user_id = $account1->user_id;
|
||||||
|
$account3->user_id = $account1->user_id;
|
||||||
|
$account1->save();
|
||||||
|
$account2->save();
|
||||||
|
$account3->save();
|
||||||
|
$this->be($account1->user);
|
||||||
|
|
||||||
|
// mock steam balance:
|
||||||
|
Steam::shouldReceive('balance')->andReturn(0, 0, 1, 2, 4, 3);
|
||||||
|
|
||||||
|
// get the result from the method:
|
||||||
|
$result = $this->object->getSavingsAccounts();
|
||||||
|
|
||||||
|
$this->assertEquals(0, $result->get(0)->difference);
|
||||||
|
$this->assertEquals(1, $result->get(1)->difference);
|
||||||
|
$this->assertEquals(-1, $result->get(2)->difference);
|
||||||
|
|
||||||
|
$this->assertEquals(100, $result->get(0)->percentage);
|
||||||
|
$this->assertEquals(100, $result->get(1)->percentage);
|
||||||
|
$this->assertEquals(25, $result->get(2)->percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -418,6 +466,13 @@ class AccountRepositoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetTransfersInRange()
|
public function testGetTransfersInRange()
|
||||||
{
|
{
|
||||||
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
|
||||||
|
$date = new Carbon;
|
||||||
|
|
||||||
|
// three transfers, two out of range:
|
||||||
|
|
||||||
|
|
||||||
// Remove the following lines when you implement this test.
|
// Remove the following lines when you implement this test.
|
||||||
$this->markTestIncomplete('This test has not been implemented yet.');
|
$this->markTestIncomplete('This test has not been implemented yet.');
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,9 @@ class ReminderRepositoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->object = new ReminderRepository;
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
$this->object = new ReminderRepository;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user