- Options
+ {{ trans('firefly.options') }}
{{ ExpandedForm.optionsList('update','transaction') }}
diff --git a/tests/factories/all.php b/tests/factories/all.php
index 4b9075a7cd..a060efcc07 100644
--- a/tests/factories/all.php
+++ b/tests/factories/all.php
@@ -1,7 +1,6 @@
'factory|FireflyIII\Models\BudgetLimit',
'startdate' => 'date',
'enddate' => 'date',
- 'amount' => 'integer',
+ 'amount' => function () {
+ return rand(1, 100);
+ },
]
);
@@ -149,7 +150,9 @@ FactoryMuffin::define(
[
'budget_id' => 'factory|FireflyIII\Models\Budget',
'startdate' => 'date',
- 'amount' => 'integer',
+ 'amount' => function () {
+ return rand(1, 100);
+ },
'repeats' => 'false',
'repeat_freq' => 'monthly',
@@ -220,7 +223,9 @@ FactoryMuffin::define(
[
'account_id' => 'factory|FireflyIII\Models\Account',
'name' => 'sentence',
- 'targetamount' => 'integer',
+ 'targetamount' => function () {
+ return rand(1, 100);
+ },
'startdate' => 'date',
'targetdate' => 'date',
'reminder_skip' => 0,
diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.php
index 5eb3ce86d3..104920040e 100644
--- a/tests/repositories/BudgetRepositoryTest.php
+++ b/tests/repositories/BudgetRepositoryTest.php
@@ -1,5 +1,10 @@
markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ // create some budgets:
+ for ($i = 0; $i < 3; $i++) {
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
+ $limit->budget_id = $budget->id;
+ $limit->amount = 0;
+ $limit->save();
+ }
+
+
+ $this->object->cleanupBudgets();
+
+ $this->assertCount(0, BudgetLimit::get());
+
}
/**
@@ -48,10 +62,11 @@ class BudgetRepositoryTest extends TestCase
*/
public function testDestroy()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $this->object->destroy($budget);
+
+ $this->assertCount(0, Budget::where('id', $budget->id)->whereNull('deleted_at')->get());
}
/**
@@ -60,213 +75,311 @@ class BudgetRepositoryTest extends TestCase
*/
public function testExpensesOnDay()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $result = $this->object->expensesOnDay($budget, new Carbon);
+
+ $this->assertEquals(0, $result);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getActiveBudgets
- * @todo Implement testGetActiveBudgets().
*/
public function testGetActiveBudgets()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget1->active = 1;
+ $budget2->active = 0;
+ $budget2->user_id = $budget1->user_id;
+ $budget1->save();
+ $budget2->save();
+ $this->be($budget1->user);
+
+ $set = $this->object->getActiveBudgets();
+
+ $this->assertCount(1, $set);
+ $this->assertEquals($set->first()->id, $budget1->id);
+
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgetLimitRepetitions
- * @todo Implement testGetBudgetLimitRepetitions().
*/
public function testGetBudgetLimitRepetitions()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $rep = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
+ $limit = $rep->budgetlimit;
+ $limit->startdate = new Carbon('2015-02-02');
+ $rep->startdate = new Carbon('2015-02-02');
+ $rep->enddate = new Carbon('2015-02-28');
+ $limit->save();
+ $rep->save();
+
+ $set = $this->object->getBudgetLimitRepetitions($rep->budgetlimit->budget, new Carbon('2015-02-01'), new Carbon('2015-02-28'));
+ $this->assertCount(2, $set);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgetLimits
- * @todo Implement testGetBudgetLimits().
*/
public function testGetBudgetLimits()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ /** @var Budget $budget */
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $set = $this->object->getBudgetLimits($budget);
+
+ $this->assertCount(0, $set);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgets
- * @todo Implement testGetBudgets().
*/
public function testGetBudgets()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget1->active = 1;
+ $budget2->active = 0;
+ $budget2->user_id = $budget1->user_id;
+ $budget1->save();
+ $budget2->save();
+ $this->be($budget1->user);
+
+ $set = $this->object->getBudgets();
+
+ $this->assertCount(2, $set);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getCurrentRepetition
- * @todo Implement testGetCurrentRepetition().
*/
public function testGetCurrentRepetition()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ /** @var Budget $budget */
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $rep = $this->object->getCurrentRepetition($budget, new Carbon);
+ $this->assertNull($rep);
+
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getFirstBudgetLimitDate
- * @todo Implement testGetFirstBudgetLimitDate().
*/
public function testGetFirstBudgetLimitDate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ /** @var BudgetLimit $budget */
+ $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
+ $date = $this->object->getFirstBudgetLimitDate($limit->budget);
+ $this->assertEquals($date->format('Y-m-d'), $limit->startdate->format('Y-m-d'));
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::getFirstBudgetLimitDate
+ */
+ public function testGetFirstBudgetLimitDateNull()
+ {
+ /** @var Budget $budget */
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $date = $this->object->getFirstBudgetLimitDate($budget);
+ $ownDate = Carbon::now()->startOfYear();
+ $this->assertEquals($date->format('Y-m-d'), $ownDate->format('Y-m-d'));
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getInactiveBudgets
- * @todo Implement testGetInactiveBudgets().
*/
public function testGetInactiveBudgets()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $budget1->active = 1;
+ $budget2->active = 0;
+ $budget2->user_id = $budget1->user_id;
+ $budget1->save();
+ $budget2->save();
+ $this->be($budget1->user);
+
+ $set = $this->object->getInactiveBudgets();
+
+ $this->assertCount(1, $set);
+ $this->assertEquals($set->first()->id, $budget2->id);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getJournals
- * @todo Implement testGetJournals().
*/
public function testGetJournals()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
+
+ $set = $this->object->getJournals($repetition->budgetlimit->budget, $repetition);
+ $this->assertTrue($set instanceof LengthAwarePaginator);
+ $this->assertCount(0, $set);
+ $this->assertEquals(1, $set->currentPage());
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getLastBudgetLimitDate
- * @todo Implement testGetLastBudgetLimitDate().
*/
public function testGetLastBudgetLimitDate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ /** @var BudgetLimit $budget */
+ $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
+ $date = $this->object->getLastBudgetLimitDate($limit->budget);
+ $this->assertEquals($date->format('Y-m-d'), $limit->startdate->format('Y-m-d'));
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLastBudgetLimitDate
+ */
+ public function testGetLastBudgetLimitDateNull()
+ {
+
+ /** @var Budget $budget */
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $date = $this->object->getLastBudgetLimitDate($budget);
+ $ownDate = Carbon::now()->startOfYear();
+ $this->assertEquals($date->format('Y-m-d'), $ownDate->format('Y-m-d'));
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getLimitAmountOnDate
- * @todo Implement testGetLimitAmountOnDate().
*/
public function testGetLimitAmountOnDate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $rep = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
+
+ $amount = $this->object->getLimitAmountOnDate($rep->budgetlimit->budget, $rep->startdate);
+
+ $this->assertEquals($rep->amount, $amount);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLimitAmountOnDate
+ */
+ public function testGetLimitAmountOnDateNull()
+ {
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $amount = $this->object->getLimitAmountOnDate($budget, new Carbon);
+
+ $this->assertNull($amount);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getWithoutBudget
- * @todo Implement testGetWithoutBudget().
*/
public function testGetWithoutBudget()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+ $set = $this->object->getWithoutBudget(new Carbon, new Carbon);
+ $this->assertCount(0, $set);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::getWithoutBudgetSum
- * @todo Implement testGetWithoutBudgetSum().
*/
public function testGetWithoutBudgetSum()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+ $sum = $this->object->getWithoutBudgetSum(new Carbon, new Carbon);
+ $this->assertEquals(0, $sum);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::spentInMonth
- * @todo Implement testSpentInMonth().
*/
public function testSpentInMonth()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $amount = $this->object->spentInMonth($budget, new Carbon);
+ $this->assertEquals(0, $amount);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::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.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+
+ $data = [
+ 'name' => 'new budget ' . rand(1, 100),
+ 'user' => $user->id
+ ];
+ $result = $this->object->store($data);
+
+ $this->assertTrue($result instanceof Budget);
+ $this->assertEquals($result->name, $data['name']);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::sumBudgetExpensesInPeriod
- * @todo Implement testSumBudgetExpensesInPeriod().
*/
public function testSumBudgetExpensesInPeriod()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $result = $this->object->sumBudgetExpensesInPeriod($budget, new Carbon, new Carbon);
+ $this->assertEquals(0, $result);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::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.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $data = [
+ 'name' => 'update budget ' . rand(1, 100),
+ 'active' => true
+ ];
+ $result = $this->object->update($budget, $data);
+
+ $this->assertTrue($result instanceof Budget);
+ $this->assertEquals($result->name, $data['name']);
+ $this->assertEquals($result->id, $budget->id);
}
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount
- * @todo Implement testUpdateLimitAmount().
*/
public function testUpdateLimitAmount()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+
+ $result = $this->object->updateLimitAmount($budget, new Carbon, 100);
+
+ $this->assertTrue($result instanceof BudgetLimit);
+ $this->assertEquals($result->amount, 100);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount
+ */
+ public function testUpdateLimitAmountExisting()
+ {
+ $budgetLimit= FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
+
+ $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 100);
+
+ $this->assertTrue($result instanceof BudgetLimit);
+ $this->assertEquals($result->amount, 100);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount
+ */
+ public function testUpdateLimitAmountZero()
+ {
+ $budgetLimit= FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
+
+ $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 0);
+
+ $this->assertTrue($result instanceof BudgetLimit);
}
}
diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.php
index e5288656c4..e17bcae14f 100644
--- a/tests/repositories/CategoryRepositoryTest.php
+++ b/tests/repositories/CategoryRepositoryTest.php
@@ -1,5 +1,8 @@
markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $result = $this->object->countJournals($category);
+
+ $this->assertEquals(0, $result);
}
/**
@@ -48,129 +50,204 @@ class CategoryRepositoryTest extends TestCase
*/
public function testDestroy()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $this->object->destroy($category);
+
+ $count = Category::where('id', $category->id)->whereNull('deleted_at')->count();
+ $this->assertEquals(0, $count);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getCategories
- * @todo Implement testGetCategories().
*/
public function testGetCategories()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $cat1 = FactoryMuffin::create('FireflyIII\Models\Category');
+ $cat2 = FactoryMuffin::create('FireflyIII\Models\Category');
+ $cat1->name = 'BBBBB';
+ $cat2->name = 'AAAAA';
+ $cat1->user_id = $user->id;
+ $cat2->user_id = $user->id;
+ $cat1->save();
+ $cat2->save();
+ $this->be($user);
+
+ $set = $this->object->getCategories();
+ $this->assertEquals('AAAAA', $set->first()->name);
+ $this->assertCount(2, $set);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getCategoriesAndExpenses
- * @todo Implement testGetCategoriesAndExpenses().
*/
public function testGetCategoriesAndExpenses()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ // some journals and categories:
+ for ($i = 0; $i < 5; $i++) {
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $journal->user_id = $user->id;
+ $journal->date = new Carbon('2015-02-11');
+ $journal->transaction_type_id = $type->id;
+ $category->user_id = $user->id;
+ $category->transactionjournals()->save($journal);
+ $journal->save();
+ $category->save();
+ }
+
+ $this->be($user);
+ $set = $this->object->getCategoriesAndExpenses(new Carbon('2015-02-01'), new Carbon('2015-02-28'));
+ $this->assertCount(5, $set);
+ $this->assertEquals(0, $set->first()->sum);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getFirstActivityDate
- * @todo Implement testGetFirstActivityDate().
*/
public function testGetFirstActivityDate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $journal->user_id = $user->id;
+ $journal->date = new Carbon('2015-02-11');
+ $category->user_id = $user->id;
+ $category->transactionjournals()->save($journal);
+ $journal->save();
+ $category->save();
+
+ $this->be($user);
+
+ $date = $this->object->getFirstActivityDate($category);
+ $this->assertEquals('2015-02-11', $date->format('Y-m-d'));
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Category\CategoryRepository::getFirstActivityDate
+ */
+ public function testGetFirstActivityDateNull()
+ {
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $this->be($category->user);
+
+ $date = $this->object->getFirstActivityDate($category);
+ $this->assertEquals(Carbon::now()->format('Y-m-d'), $date->format('Y-m-d'));
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getJournals
- * @todo Implement testGetJournals().
*/
public function testGetJournals()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $this->be($category->user);
+ $set = $this->object->getJournals($category, 1);
+
+ $this->assertEquals(0, $set->count());
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getLatestActivity
- * @todo Implement testGetLatestActivity().
*/
public function testGetLatestActivity()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $journal->user_id = $user->id;
+ $journal->date = new Carbon('2015-02-11');
+ $category->user_id = $user->id;
+ $category->transactionjournals()->save($journal);
+ $journal->save();
+ $category->save();
+
+ $this->be($user);
+
+ $date = $this->object->getLatestActivity($category);
+ $this->assertEquals('2015-02-11', $date->format('Y-m-d'));
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::getWithoutCategory
- * @todo Implement testGetWithoutCategory().
*/
public function testGetWithoutCategory()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+
+ $set = $this->object->getWithoutCategory(new Carbon, new Carbon);
+ $this->assertCount(0, $set);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::spentInPeriodSum
- * @todo Implement testSpentInPeriodSum().
*/
public function testSpentInPeriodSum()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $sum = $this->object->spentInPeriodSum($category, new Carbon, new Carbon);
+
+ $this->assertEquals(0, $sum);
+
+
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::spentOnDaySum
- * @todo Implement testSpentOnDaySum().
*/
public function testSpentOnDaySum()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $sum = $this->object->spentOnDaySum($category, new Carbon);
+
+ $this->assertEquals(0, $sum);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::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.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'name' => 'New category' . rand(1, 100),
+ 'user' => $user->id
+ ];
+ $newCategory = $this->object->store($data);
+
+ $this->assertEquals($data['name'], $newCategory->name);
}
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::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.'
- );
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $data = [
+ 'name' => 'New category' . rand(1, 100),
+ ];
+ $newCategory = $this->object->update($category, $data);
+
+ $this->assertEquals($data['name'], $newCategory->name);
+ }
+
+ public function testgetLatestActivityNull()
+ {
+ /** @var Category $category */
+ $category = FactoryMuffin::create('FireflyIII\Models\Category');
+ $this->be($category->user);
+
+ $date = $this->object->getLatestActivity($category);
+ $this->assertNull($date);
}
}
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 @@
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);
}
}