Fixed some test coverage.

This commit is contained in:
James Cole
2015-06-07 10:28:26 +02:00
parent a27471ae55
commit 0be5b27d34
5 changed files with 74 additions and 2 deletions

View File

@@ -163,7 +163,7 @@ class Amount
return $currency->code; return $currency->code;
} }
return 'EUR'; return 'EUR'; // @codeCoverageIgnore
} }
/** /**

View File

@@ -13,6 +13,7 @@ use Preferences as Prefs;
/** /**
* Class CacheProperties * Class CacheProperties
* *
* @codeCoverageIgnore
* @package FireflyIII\Support * @package FireflyIII\Support
*/ */
class CacheProperties class CacheProperties

View File

@@ -57,6 +57,8 @@ class TransactionJournalModelTest extends TestCase
/** /**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @covers FireflyIII\Models\TransactionJournal::amountByTag
* @covers FireflyIII\Models\TransactionJournal::amountByTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public function testGetAmountAttributeAdvancePayment() public function testGetAmountAttributeAdvancePayment()
@@ -115,8 +117,11 @@ class TransactionJournalModelTest extends TestCase
} }
/** /**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @covers FireflyIII\Models\TransactionJournal::amountByTag
* @covers FireflyIII\Models\TransactionJournal::amountByTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public function testGetAmountAttributeBalancingAct() public function testGetAmountAttributeBalancingAct()
@@ -178,6 +183,8 @@ class TransactionJournalModelTest extends TestCase
/** /**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @covers FireflyIII\Models\TransactionJournal::amountByTag
* @covers FireflyIII\Models\TransactionJournal::amountByTags
*/ */
public function testGetAmountAttributeNoTags() public function testGetAmountAttributeNoTags()
{ {
@@ -197,6 +204,8 @@ class TransactionJournalModelTest extends TestCase
/** /**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @covers FireflyIII\Models\TransactionJournal::amountByTag
* @covers FireflyIII\Models\TransactionJournal::amountByTags
*/ */
public function testGetAmountAttributeTag() public function testGetAmountAttributeTag()
{ {
@@ -233,6 +242,51 @@ class TransactionJournalModelTest extends TestCase
$this->assertEquals('300', $withdrawal->amount); $this->assertEquals('300', $withdrawal->amount);
}
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
* @covers FireflyIII\Models\TransactionJournal::amountByTag
* @covers FireflyIII\Models\TransactionJournal::amountByTags
*/
public function testGetAmountAttributeTags()
{
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// has two normal tags:
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->tagMode = 'nothing';
$tag->save();
$tag2 = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag2->tagMode = 'nothing';
$tag2->save();
// make withdrawal
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$withdrawal->transaction_type_id = $withdrawalType->id;
$withdrawal->save();
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
$withdrawal->transactions[0]->amount = -300;
$withdrawal->transactions[0]->account_id = $asset->id;
$withdrawal->transactions[0]->save();
$withdrawal->transactions[1]->amount = 300;
$withdrawal->transactions[1]->account_id = $expense->id;
$withdrawal->transactions[1]->save();
// connect to tag:
$tag->transactionJournals()->save($withdrawal);
$tag2->transactionJournals()->save($withdrawal);
$this->assertEquals('300', $withdrawal->amount);
} }
@@ -365,7 +419,7 @@ class TransactionJournalModelTest extends TestCase
} }
/** /**
* @covers FireflyIII\Models\TransactionJournal::getDestinationAccountAttribute * @covers FireflyIII\Models\TransactionJournal::getSourceAccountAttribute
*/ */
public function testGetSourceAccountAttribute() public function testGetSourceAccountAttribute()
{ {

View File

@@ -300,6 +300,8 @@ class BillRepositoryTest extends TestCase
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @covers FireflyIII\Repositories\Bill\BillRepository::scan * @covers FireflyIII\Repositories\Bill\BillRepository::scan
* @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
* @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/ */
public function testScanMatch() public function testScanMatch()
{ {
@@ -329,6 +331,8 @@ class BillRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Bill\BillRepository::scan * @covers FireflyIII\Repositories\Bill\BillRepository::scan
* @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
* @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/ */
public function testScanNoMatch() public function testScanNoMatch()
{ {
@@ -370,6 +374,8 @@ class BillRepositoryTest extends TestCase
/** /**
* @covers FireflyIII\Repositories\Bill\BillRepository::scan * @covers FireflyIII\Repositories\Bill\BillRepository::scan
* @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
* @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/ */
public function testScanNoMatchButAttached() public function testScanNoMatchButAttached()
{ {

View File

@@ -36,6 +36,17 @@ class AmountSupportTest extends TestCase
parent::tearDown(); parent::tearDown();
} }
/**
* @covers FireflyIII\Support\Amount::format
* @covers FireflyIII\Support\Amount::getCurrencySymbol
*/
public function testFormat()
{
$amount = '123';
$result = $this->object->format($amount, true);
$this->assertTrue(str_contains($result, $amount));
}
/** /**
* @covers FireflyIII\Support\Amount::formatJournal * @covers FireflyIII\Support\Amount::formatJournal
*/ */