Skip to content

Firefly III: a personal finances manager

Covered currency repository.

James Cole506ef7b0b944
diff --git a/tests/repositories/CurrencyRepositoryTest.php b/tests/repositories/CurrencyRepositoryTest.php
index 756991dd3d..221ea6ec15 100644
--- a/tests/repositories/CurrencyRepositoryTest.php
+++ b/tests/repositories/CurrencyRepositoryTest.php
@@ -1,5 +1,6 @@
<?php
use FireflyIII\Repositories\Currency\CurrencyRepository;
+use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
@@ -32,61 +33,82 @@ class CurrencyRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Currency\CurrencyRepository::countJournals
- * @todo Implement testCountJournals().
*/
public function testCountJournals()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $count = $this->object->countJournals($currency);
+ $this->assertEquals(0, $count);
}
/**
* @covers FireflyIII\Repositories\Currency\CurrencyRepository::get
- * @todo Implement testGet().
*/
public function testGet()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+
+ $set = $this->object->get();
+ $this->assertCount(2, $set);
}
/**
* @covers FireflyIII\Repositories\Currency\CurrencyRepository::getCurrencyByPreference
- * @todo Implement testGetCurrencyByPreference().
*/
public function testGetCurrencyByPreference()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $preference = FactoryMuffin::create('FireflyIII\Models\Preference');
+ $preference->data = $currency->code;
+ $preference->save();
+ $found = $this->object->getCurrencyByPreference($preference);
+ $this->assertEquals($currency->id, $found->id);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Currency\CurrencyRepository::getCurrencyByPreference
+ */
+ public function testGetCurrencyByPreferenceNull()
+ {
+ $first = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $preference = FactoryMuffin::create('FireflyIII\Models\Preference');
+ $preference->data = 'ABC';
+ $preference->save();
+ $found = $this->object->getCurrencyByPreference($preference);
+ $this->assertEquals($first->id, $found->id);
}
/**
* @covers FireflyIII\Repositories\Currency\CurrencyRepository::store
- * @todo Implement testStore().
*/
public function testStore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $data = [
+ 'name' => 'Some Currency',
+ 'code' => 'ABC',
+ 'symbol' => 'S'
+ ];
+
+ $currency = $this->object->store($data);
+ $this->assertEquals($data['name'], $currency->name);
}
/**
* @covers FireflyIII\Repositories\Currency\CurrencyRepository::update
- * @todo Implement testUpdate().
*/
public function testUpdate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+
+ $data = [
+ 'name' => 'Some Currency',
+ 'code' => 'ABC',
+ 'symbol' => 'S'
+ ];
+
+ $newCurrency = $this->object->update($currency, $data);
+ $this->assertEquals($data['name'], $newCurrency->name);
+ $this->assertEquals($currency->id, $newCurrency->id);
}
}