Skip to content

Firefly III: a personal finances manager

Fixed some test coverage.

James Cole0be5b27d345c
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 0d4c2a6534..c9a494f3f5 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -163,7 +163,7 @@ class Amount
return $currency->code;
}
- return 'EUR';
+ return 'EUR'; // @codeCoverageIgnore
}
/**
diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php
index b4854503d0..ba2d654b3d 100644
--- a/app/Support/CacheProperties.php
+++ b/app/Support/CacheProperties.php
@@ -13,6 +13,7 @@ use Preferences as Prefs;
/**
* Class CacheProperties
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support
*/
class CacheProperties
diff --git a/tests/models/TransactionJournalModelTest.php b/tests/models/TransactionJournalModelTest.php
index fb1f9256d3..c9e007d65f 100644
--- a/tests/models/TransactionJournalModelTest.php
+++ b/tests/models/TransactionJournalModelTest.php
@@ -57,6 +57,8 @@ class TransactionJournalModelTest extends TestCase
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
+ * @covers FireflyIII\Models\TransactionJournal::amountByTag
+ * @covers FireflyIII\Models\TransactionJournal::amountByTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetAmountAttributeAdvancePayment()
@@ -115,8 +117,11 @@ class TransactionJournalModelTest extends TestCase
}
+
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
+ * @covers FireflyIII\Models\TransactionJournal::amountByTag
+ * @covers FireflyIII\Models\TransactionJournal::amountByTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetAmountAttributeBalancingAct()
@@ -178,6 +183,8 @@ class TransactionJournalModelTest extends TestCase
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
+ * @covers FireflyIII\Models\TransactionJournal::amountByTag
+ * @covers FireflyIII\Models\TransactionJournal::amountByTags
*/
public function testGetAmountAttributeNoTags()
{
@@ -197,6 +204,8 @@ class TransactionJournalModelTest extends TestCase
/**
* @covers FireflyIII\Models\TransactionJournal::getAmountAttribute
+ * @covers FireflyIII\Models\TransactionJournal::amountByTag
+ * @covers FireflyIII\Models\TransactionJournal::amountByTags
*/
public function testGetAmountAttributeTag()
{
@@ -233,6 +242,51 @@ class TransactionJournalModelTest extends TestCase
$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()
{
diff --git a/tests/repositories/BillRepositoryTest.php b/tests/repositories/BillRepositoryTest.php
index 57ef8932e0..36356391f5 100644
--- a/tests/repositories/BillRepositoryTest.php
+++ b/tests/repositories/BillRepositoryTest.php
@@ -300,6 +300,8 @@ class BillRepositoryTest extends TestCase
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @covers FireflyIII\Repositories\Bill\BillRepository::scan
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/
public function testScanMatch()
{
@@ -329,6 +331,8 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::scan
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/
public function testScanNoMatch()
{
@@ -370,6 +374,8 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::scan
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch
+ * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch
*/
public function testScanNoMatchButAttached()
{
diff --git a/tests/support/AmountSupportTest.php b/tests/support/AmountSupportTest.php
index 66c4882cc7..e297291b19 100644
--- a/tests/support/AmountSupportTest.php
+++ b/tests/support/AmountSupportTest.php
@@ -36,6 +36,17 @@ class AmountSupportTest extends TestCase
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
*/