Covered some more lines of code.

This commit is contained in:
James Cole 2015-01-02 13:57:40 +01:00
parent 61d60a9048
commit da0c0742bf
3 changed files with 20 additions and 3 deletions

View File

@ -59,15 +59,19 @@ class TransactionJournal extends Eloquent
*/
public function getAmount(\Account $account = null)
{
$amount = 0;
foreach ($this->transactions as $t) {
if (!is_null($account) && $account->id == $t->account_id) {
return floatval($t->amount);
$amount = floatval($t->amount);
break;
}
if (floatval($t->amount) > 0) {
return floatval($t->amount);
$amount = floatval($t->amount);
break;
}
}
return $amount;
}
/**

View File

@ -106,6 +106,17 @@ class TransactionControllerCest
$I->see(intval($journal->getAmount()));
}
public function showGroupedJournal(FunctionalTester $I)
{
$journal = TransactionJournal::where('description', 'LIKE', 'Big expense in %')->first();
$I->wantTo('see a grouped transaction');
$I->amOnPage('/transaction/show/' . $journal->id);
$I->see($journal->description);
$I->see('Money for '.$journal->description);
}
public function store(FunctionalTester $I)
{
$I->wantTo('store a transaction');

View File

@ -23,12 +23,14 @@ class UserTest extends TestCase
{
$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());
}
}