From cbb62d3d78e16cbe2c195b4fed302dabfce19048 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 12:51:57 +0200 Subject: [PATCH 01/14] Added new line at the end of files. [skip ci] --- app/Helpers/Help/Help.php | 2 +- app/Helpers/Help/HelpInterface.php | 2 +- app/Http/Controllers/TagController.php | 2 +- app/Http/Requests/TagFormRequest.php | 2 +- app/Http/breadcrumbs.php | 2 +- app/Models/Tag.php | 2 +- app/Repositories/Tag/TagRepository.php | 2 +- app/Repositories/Tag/TagRepositoryInterface.php | 2 +- app/Support/Twig/Budget.php | 2 +- app/Support/Twig/General.php | 2 +- app/Support/Twig/Journal.php | 2 +- app/Support/Twig/PiggyBank.php | 2 +- resources/twig/accounts/create.twig | 2 +- resources/twig/accounts/show.twig | 2 +- resources/twig/auth/password.twig | 2 +- resources/twig/bills/delete.twig | 2 +- resources/twig/bills/index.twig | 2 +- resources/twig/bills/show.twig | 2 +- resources/twig/budgets/delete.twig | 2 +- resources/twig/budgets/noBudget.twig | 2 +- resources/twig/categories/index.twig | 2 +- resources/twig/categories/noCategory.twig | 2 +- resources/twig/categories/show.twig | 2 +- resources/twig/currency/delete.twig | 2 +- resources/twig/currency/edit.twig | 2 +- resources/twig/currency/index.twig | 2 +- resources/twig/form/options.twig | 2 +- resources/twig/index.twig | 2 +- resources/twig/list/accounts.twig | 2 +- resources/twig/list/journals.twig | 2 +- resources/twig/list/piggy-banks.twig | 2 +- resources/twig/piggy-banks/index.twig | 2 +- resources/twig/piggy-banks/remove.twig | 2 +- resources/twig/profile/change-password.twig | 2 +- resources/twig/profile/delete-account.twig | 2 +- resources/twig/profile/index.twig | 2 +- resources/twig/reminders/show.twig | 2 +- resources/twig/search/index.twig | 2 +- resources/twig/tags/create.twig | 2 +- resources/twig/tags/edit.twig | 2 +- resources/twig/tags/index.twig | 2 +- tests/controllers/BillControllerTest.php | 2 +- tests/controllers/BudgetControllerTest.php | 2 +- tests/controllers/CategoryControllerTest.php | 2 +- tests/controllers/CurrencyControllerTest.php | 2 +- tests/controllers/GoogleChartControllerTest.php | 2 +- tests/controllers/HelpControllerTest.php | 2 +- tests/controllers/JsonControllerTest.php | 2 +- tests/controllers/PreferencesControllerTest.php | 2 +- tests/controllers/ProfileControllerTest.php | 2 +- tests/controllers/ReminderControllerTest.php | 2 +- tests/controllers/ReportControllerTest.php | 2 +- tests/controllers/SearchControllerTest.php | 2 +- tests/controllers/TagControllerTest.php | 2 +- tests/controllers/TransactionControllerTest.php | 2 +- tests/database/.gitignore | 2 +- tests/factories/all.php | 2 +- 57 files changed, 57 insertions(+), 57 deletions(-) diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index c7e77a5d2d..eddad2614f 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -84,4 +84,4 @@ class Help implements HelpInterface { return Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text'); } -} \ No newline at end of file +} diff --git a/app/Helpers/Help/HelpInterface.php b/app/Helpers/Help/HelpInterface.php index b11e29b4ab..3807c2c1ff 100644 --- a/app/Helpers/Help/HelpInterface.php +++ b/app/Helpers/Help/HelpInterface.php @@ -45,4 +45,4 @@ interface HelpInterface * @return void */ public function putInCache($route, array $content); -} \ No newline at end of file +} diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 5d54937c4e..34d7364663 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -322,4 +322,4 @@ class TagController extends Controller // redirect to previous URL. return Redirect::to(Session::get('tags.edit.url')); } -} \ No newline at end of file +} diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php index ad04f50a29..3909b177b2 100644 --- a/app/Http/Requests/TagFormRequest.php +++ b/app/Http/Requests/TagFormRequest.php @@ -50,4 +50,4 @@ class TagFormRequest extends Request 'tagMode' => 'required|in:nothing,balancingAct,advancePayment' ]; } -} \ No newline at end of file +} diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 672ae8ff5a..7705a04648 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -415,4 +415,4 @@ Breadcrumbs::register( $breadcrumbs->parent('tags.index'); $breadcrumbs->push(e($tag->tag), route('tags.show', $tag->id)); } -); \ No newline at end of file +); diff --git a/app/Models/Tag.php b/app/Models/Tag.php index cac823555c..11ce119559 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -125,4 +125,4 @@ class Tag extends Model { return $this->belongsTo('FireflyIII\User'); } -} \ No newline at end of file +} diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 301fedb267..0fc8c4b42b 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -177,4 +177,4 @@ class TagRepository implements TagRepositoryInterface return $tag; } -} \ No newline at end of file +} diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index e2a5c03bff..94d5e44cb2 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -49,4 +49,4 @@ interface TagRepositoryInterface * @return boolean */ public function connect(TransactionJournal $journal, Tag $tag); -} \ No newline at end of file +} diff --git a/app/Support/Twig/Budget.php b/app/Support/Twig/Budget.php index 39ec2a1e04..046e741446 100644 --- a/app/Support/Twig/Budget.php +++ b/app/Support/Twig/Budget.php @@ -50,4 +50,4 @@ class Budget extends Twig_Extension { return 'FireflyIII\Support\Twig\Budget'; } -} \ No newline at end of file +} diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 0be9007420..1d36857366 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -143,4 +143,4 @@ class General extends Twig_Extension return 'FireflyIII\Support\Twig\General'; } -} \ No newline at end of file +} diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index 70c088281e..aa56a310c0 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -96,4 +96,4 @@ class Journal extends Twig_Extension { return 'FireflyIII\Support\Twig\Journals'; } -} \ No newline at end of file +} diff --git a/app/Support/Twig/PiggyBank.php b/app/Support/Twig/PiggyBank.php index df4137670b..6ff4aafe90 100644 --- a/app/Support/Twig/PiggyBank.php +++ b/app/Support/Twig/PiggyBank.php @@ -39,4 +39,4 @@ class PiggyBank extends Twig_Extension { return 'FireflyIII\Support\Twig\PiggyBank'; } -} \ No newline at end of file +} diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index 6ed1f2dfaf..0314aa8892 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -58,4 +58,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/accounts/show.twig b/resources/twig/accounts/show.twig index 59ea7654ae..6822a6833c 100644 --- a/resources/twig/accounts/show.twig +++ b/resources/twig/accounts/show.twig @@ -57,4 +57,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/auth/password.twig b/resources/twig/auth/password.twig index 720bce9a88..8d209f1ab4 100644 --- a/resources/twig/auth/password.twig +++ b/resources/twig/auth/password.twig @@ -42,4 +42,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/bills/delete.twig b/resources/twig/bills/delete.twig index f58fd3db68..ff205c0f50 100644 --- a/resources/twig/bills/delete.twig +++ b/resources/twig/bills/delete.twig @@ -29,4 +29,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/bills/index.twig b/resources/twig/bills/index.twig index ef488037a5..96b0ba7949 100644 --- a/resources/twig/bills/index.twig +++ b/resources/twig/bills/index.twig @@ -24,4 +24,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/bills/show.twig b/resources/twig/bills/show.twig index e6297668a7..5c3ed858f9 100644 --- a/resources/twig/bills/show.twig +++ b/resources/twig/bills/show.twig @@ -110,4 +110,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/budgets/delete.twig b/resources/twig/budgets/delete.twig index e1b7e5ef95..ea7450b25f 100644 --- a/resources/twig/budgets/delete.twig +++ b/resources/twig/budgets/delete.twig @@ -40,4 +40,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/budgets/noBudget.twig b/resources/twig/budgets/noBudget.twig index 2ff705afe8..51de6c5954 100644 --- a/resources/twig/budgets/noBudget.twig +++ b/resources/twig/budgets/noBudget.twig @@ -14,4 +14,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/categories/index.twig b/resources/twig/categories/index.twig index 82e98ac0e1..ae3c267a26 100644 --- a/resources/twig/categories/index.twig +++ b/resources/twig/categories/index.twig @@ -37,4 +37,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/categories/noCategory.twig b/resources/twig/categories/noCategory.twig index e85d86c942..fa4ec948a0 100644 --- a/resources/twig/categories/noCategory.twig +++ b/resources/twig/categories/noCategory.twig @@ -15,4 +15,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/categories/show.twig b/resources/twig/categories/show.twig index b830ccacf0..c231eb8d18 100644 --- a/resources/twig/categories/show.twig +++ b/resources/twig/categories/show.twig @@ -51,4 +51,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/currency/delete.twig b/resources/twig/currency/delete.twig index b90be97c5c..b3fa433820 100644 --- a/resources/twig/currency/delete.twig +++ b/resources/twig/currency/delete.twig @@ -23,4 +23,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/currency/edit.twig b/resources/twig/currency/edit.twig index 8d356fcf4f..11b33708df 100644 --- a/resources/twig/currency/edit.twig +++ b/resources/twig/currency/edit.twig @@ -42,4 +42,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/currency/index.twig b/resources/twig/currency/index.twig index 77e928bee6..b807479e90 100644 --- a/resources/twig/currency/index.twig +++ b/resources/twig/currency/index.twig @@ -46,4 +46,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/form/options.twig b/resources/twig/form/options.twig index 9af8428ba2..5ba3fcb96d 100644 --- a/resources/twig/form/options.twig +++ b/resources/twig/form/options.twig @@ -27,4 +27,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/resources/twig/index.twig b/resources/twig/index.twig index e3c94d519f..990aa88fdc 100644 --- a/resources/twig/index.twig +++ b/resources/twig/index.twig @@ -209,4 +209,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/list/accounts.twig b/resources/twig/list/accounts.twig index 200f09eb04..4cc47af39a 100644 --- a/resources/twig/list/accounts.twig +++ b/resources/twig/list/accounts.twig @@ -56,4 +56,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twig index 860917c836..21c3742665 100644 --- a/resources/twig/list/journals.twig +++ b/resources/twig/list/journals.twig @@ -110,4 +110,4 @@ {% endfor %} -{{ journals.render|raw }} \ No newline at end of file +{{ journals.render|raw }} diff --git a/resources/twig/list/piggy-banks.twig b/resources/twig/list/piggy-banks.twig index ef6cf6be63..b247b253de 100644 --- a/resources/twig/list/piggy-banks.twig +++ b/resources/twig/list/piggy-banks.twig @@ -53,4 +53,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/resources/twig/piggy-banks/index.twig b/resources/twig/piggy-banks/index.twig index d0d2563fb6..14e1481426 100644 --- a/resources/twig/piggy-banks/index.twig +++ b/resources/twig/piggy-banks/index.twig @@ -59,4 +59,4 @@ {% block scripts %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/piggy-banks/remove.twig b/resources/twig/piggy-banks/remove.twig index 657ce02431..529dd6c66e 100644 --- a/resources/twig/piggy-banks/remove.twig +++ b/resources/twig/piggy-banks/remove.twig @@ -23,4 +23,4 @@ - \ No newline at end of file + diff --git a/resources/twig/profile/change-password.twig b/resources/twig/profile/change-password.twig index 16900564f3..0a0cbde5be 100644 --- a/resources/twig/profile/change-password.twig +++ b/resources/twig/profile/change-password.twig @@ -52,4 +52,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/profile/delete-account.twig b/resources/twig/profile/delete-account.twig index f3e5f94e1c..a47c929b32 100644 --- a/resources/twig/profile/delete-account.twig +++ b/resources/twig/profile/delete-account.twig @@ -46,4 +46,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/profile/index.twig b/resources/twig/profile/index.twig index 244a1a6e35..525da37b25 100644 --- a/resources/twig/profile/index.twig +++ b/resources/twig/profile/index.twig @@ -16,4 +16,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/reminders/show.twig b/resources/twig/reminders/show.twig index b78eb138a0..da560949eb 100644 --- a/resources/twig/reminders/show.twig +++ b/resources/twig/reminders/show.twig @@ -37,4 +37,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/search/index.twig b/resources/twig/search/index.twig index a4783911cc..c00b12b931 100644 --- a/resources/twig/search/index.twig +++ b/resources/twig/search/index.twig @@ -103,4 +103,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/tags/create.twig b/resources/twig/tags/create.twig index ab957ce3bf..7c79e29cb5 100644 --- a/resources/twig/tags/create.twig +++ b/resources/twig/tags/create.twig @@ -82,4 +82,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/tags/edit.twig b/resources/twig/tags/edit.twig index 85f5e3503f..6ad950374c 100644 --- a/resources/twig/tags/edit.twig +++ b/resources/twig/tags/edit.twig @@ -84,4 +84,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/resources/twig/tags/index.twig b/resources/twig/tags/index.twig index 9b520969a5..94b1e5553a 100644 --- a/resources/twig/tags/index.twig +++ b/resources/twig/tags/index.twig @@ -72,4 +72,4 @@ {% endblock %} {% block scripts %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/tests/controllers/BillControllerTest.php b/tests/controllers/BillControllerTest.php index 846e63298a..e217bdef89 100644 --- a/tests/controllers/BillControllerTest.php +++ b/tests/controllers/BillControllerTest.php @@ -253,4 +253,4 @@ class BillControllerTest extends TestCase $this->assertResponseStatus(302); } -} \ No newline at end of file +} diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.php index edacbcd133..9a397fc61d 100644 --- a/tests/controllers/BudgetControllerTest.php +++ b/tests/controllers/BudgetControllerTest.php @@ -316,4 +316,4 @@ class BudgetControllerTest extends TestCase $this->assertResponseOk(); $this->assertViewHas('amount'); } -} \ No newline at end of file +} diff --git a/tests/controllers/CategoryControllerTest.php b/tests/controllers/CategoryControllerTest.php index c4ca304ce6..a33a900b0c 100644 --- a/tests/controllers/CategoryControllerTest.php +++ b/tests/controllers/CategoryControllerTest.php @@ -222,4 +222,4 @@ class CategoryControllerTest extends TestCase $this->assertResponseStatus(302); $this->assertSessionHas('success', 'Category "' . $category->name . '" updated.'); } -} \ No newline at end of file +} diff --git a/tests/controllers/CurrencyControllerTest.php b/tests/controllers/CurrencyControllerTest.php index b06e1cb67a..64ef026fb7 100644 --- a/tests/controllers/CurrencyControllerTest.php +++ b/tests/controllers/CurrencyControllerTest.php @@ -214,4 +214,4 @@ class CurrencyControllerTest extends TestCase $this->assertResponseStatus(302); $this->assertSessionHas('success'); } -} \ No newline at end of file +} diff --git a/tests/controllers/GoogleChartControllerTest.php b/tests/controllers/GoogleChartControllerTest.php index 89ebf3ef20..ed7bdf2969 100644 --- a/tests/controllers/GoogleChartControllerTest.php +++ b/tests/controllers/GoogleChartControllerTest.php @@ -344,4 +344,4 @@ class GoogleChartControllerTest extends TestCase $this->call('GET', '/chart/reports/income-expenses-sum/2015'); } -} \ No newline at end of file +} diff --git a/tests/controllers/HelpControllerTest.php b/tests/controllers/HelpControllerTest.php index d6a6f23128..91c79255e7 100644 --- a/tests/controllers/HelpControllerTest.php +++ b/tests/controllers/HelpControllerTest.php @@ -95,4 +95,4 @@ class HelpControllerTest extends TestCase $this->call('GET', '/help/accounts.index'); $this->assertResponseOk(); } -} \ No newline at end of file +} diff --git a/tests/controllers/JsonControllerTest.php b/tests/controllers/JsonControllerTest.php index de5c95e6cd..8d34d94b9f 100644 --- a/tests/controllers/JsonControllerTest.php +++ b/tests/controllers/JsonControllerTest.php @@ -224,4 +224,4 @@ class JsonControllerTest extends TestCase $this->assertResponseOk(); } -} \ No newline at end of file +} diff --git a/tests/controllers/PreferencesControllerTest.php b/tests/controllers/PreferencesControllerTest.php index e45178a308..2d843d2bed 100644 --- a/tests/controllers/PreferencesControllerTest.php +++ b/tests/controllers/PreferencesControllerTest.php @@ -82,4 +82,4 @@ class PreferencesControllerTest extends TestCase $this->call('POST', '/preferences', $data); $this->assertResponseStatus(302); } -} \ No newline at end of file +} diff --git a/tests/controllers/ProfileControllerTest.php b/tests/controllers/ProfileControllerTest.php index 8bc447f12b..30bb3b6c70 100644 --- a/tests/controllers/ProfileControllerTest.php +++ b/tests/controllers/ProfileControllerTest.php @@ -167,4 +167,4 @@ class ProfileControllerTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/controllers/ReminderControllerTest.php b/tests/controllers/ReminderControllerTest.php index 43ab7a69c1..db993916b0 100644 --- a/tests/controllers/ReminderControllerTest.php +++ b/tests/controllers/ReminderControllerTest.php @@ -97,4 +97,4 @@ class ReminderControllerTest extends TestCase $this->assertResponseOk(); } -} \ No newline at end of file +} diff --git a/tests/controllers/ReportControllerTest.php b/tests/controllers/ReportControllerTest.php index f75204ef6e..dfe6f6c0a7 100644 --- a/tests/controllers/ReportControllerTest.php +++ b/tests/controllers/ReportControllerTest.php @@ -235,4 +235,4 @@ class ReportControllerTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/controllers/SearchControllerTest.php b/tests/controllers/SearchControllerTest.php index f4c3a6f8b7..0327cbcd07 100644 --- a/tests/controllers/SearchControllerTest.php +++ b/tests/controllers/SearchControllerTest.php @@ -52,4 +52,4 @@ class SearchControllerTest extends TestCase $this->call('GET', '/search?q=Something'); $this->assertResponseOk(); } -} \ No newline at end of file +} diff --git a/tests/controllers/TagControllerTest.php b/tests/controllers/TagControllerTest.php index bdbab15d69..6b50ca1d91 100644 --- a/tests/controllers/TagControllerTest.php +++ b/tests/controllers/TagControllerTest.php @@ -214,4 +214,4 @@ class TagControllerTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/controllers/TransactionControllerTest.php b/tests/controllers/TransactionControllerTest.php index 6902808bc4..6258d8b06a 100644 --- a/tests/controllers/TransactionControllerTest.php +++ b/tests/controllers/TransactionControllerTest.php @@ -360,4 +360,4 @@ class TransactionControllerTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/database/.gitignore b/tests/database/.gitignore index 6a91a439ea..9b1dffd90f 100644 --- a/tests/database/.gitignore +++ b/tests/database/.gitignore @@ -1 +1 @@ -*.sqlite \ No newline at end of file +*.sqlite diff --git a/tests/factories/all.php b/tests/factories/all.php index d00a36ea9a..07a1c1f529 100644 --- a/tests/factories/all.php +++ b/tests/factories/all.php @@ -267,4 +267,4 @@ FactoryMuffin::define( 'encrypted' => '1', 'order' => '0', ] -); \ No newline at end of file +); From f331e7d8205e06027895bb8bcbe85225e295aed0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 12:57:27 +0200 Subject: [PATCH 02/14] Removed unnecessary imports (use statements) [skip ci] --- .../Events/UpdateJournalConnection.php | 1 - app/Http/Controllers/BudgetController.php | 1 - app/Http/Controllers/JsonController.php | 40 +++++++++---------- app/Http/Controllers/PiggyBankController.php | 2 - app/Providers/EventServiceProvider.php | 1 - app/Providers/FireflyServiceProvider.php | 1 - app/Repositories/Bill/BillRepository.php | 2 +- .../Category/CategoryRepositoryInterface.php | 6 +-- app/Support/ExpandedForm.php | 1 - app/Support/Navigation.php | 2 +- app/Support/Search/Search.php | 1 + app/Support/Steam.php | 4 +- app/Support/Twig/Journal.php | 1 + 13 files changed, 28 insertions(+), 35 deletions(-) diff --git a/app/Handlers/Events/UpdateJournalConnection.php b/app/Handlers/Events/UpdateJournalConnection.php index 20803aacf4..f18f0bf17e 100644 --- a/app/Handlers/Events/UpdateJournalConnection.php +++ b/app/Handlers/Events/UpdateJournalConnection.php @@ -2,7 +2,6 @@ use FireflyIII\Events\JournalSaved; use FireflyIII\Models\PiggyBankEvent; -use FireflyIII\Models\Transaction; /** * Class UpdateJournalConnection diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 5dcca9fc59..27205a295b 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -5,7 +5,6 @@ use Carbon\Carbon; use FireflyIII\Http\Requests; use FireflyIII\Http\Requests\BudgetFormRequest; use FireflyIII\Models\Budget; -use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\LimitRepetition; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use Input; diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 02c326d2fd..43863523c9 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -6,8 +6,6 @@ use FireflyIII\Helpers\Report\ReportQueryInterface; use FireflyIII\Models\Account; use FireflyIII\Models\Bill; use FireflyIII\Models\Preference; -use FireflyIII\Models\Transaction; -use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; @@ -187,25 +185,6 @@ class JsonController extends Controller } - /** - * Returns a JSON list of all beneficiaries. - * - * @param TagRepositoryInterface $tagRepository - * - * @return \Illuminate\Http\JsonResponse - */ - public function tags(TagRepositoryInterface $tagRepository) - { - $list = $tagRepository->get(); - $return = []; - foreach ($list as $entry) { - $return[] = $entry->tag; - } - - return Response::json($return); - - } - /** * @param AccountRepositoryInterface $accountRepository * @@ -247,6 +226,25 @@ class JsonController extends Controller return Response::json(['value' => $pref->data]); } + /** + * Returns a JSON list of all beneficiaries. + * + * @param TagRepositoryInterface $tagRepository + * + * @return \Illuminate\Http\JsonResponse + */ + public function tags(TagRepositoryInterface $tagRepository) + { + $list = $tagRepository->get(); + $return = []; + foreach ($list as $entry) { + $return[] = $entry->tag; + } + + return Response::json($return); + + } + /** * @param JournalRepositoryInterface $repository * @param $what diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 6799f4d8d3..8ffa215491 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -6,9 +6,7 @@ use Config; use ExpandedForm; use FireflyIII\Http\Requests; use FireflyIII\Http\Requests\PiggyBankFormRequest; -use FireflyIII\Models\Account; use FireflyIII\Models\PiggyBank; -use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use Illuminate\Support\Collection; diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a9d54e9e0f..0c85491199 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -1,7 +1,6 @@ repeat_freq, 0); $skip = $bill->skip + 1; diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php index 3cf025e354..30456995a1 100644 --- a/app/Repositories/Category/CategoryRepositoryInterface.php +++ b/app/Repositories/Category/CategoryRepositoryInterface.php @@ -71,9 +71,9 @@ interface CategoryRepositoryInterface public function getWithoutCategory(Carbon $start, Carbon $end); /** - * @param Category $category - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end + * @param Category $category + * @param \Carbon\Carbon $start + * @param \Carbon\Carbon $end * * @return float */ diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index a28c87ba02..35eb8855b9 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -3,7 +3,6 @@ namespace FireflyIII\Support; use Amount as Amt; -use FireflyIII\Models\TransactionCurrency; use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; use Input; diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 69025ba3b2..470089f369 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -384,7 +384,7 @@ class Navigation } /** - * @param $range + * @param $range * @param \Carbon\Carbon $start * * @return \Carbon\Carbon diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index e07e538ecf..a493ad0741 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -121,6 +121,7 @@ class Search implements SearchInterface return $journal; } } + return null; } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 8206024886..22fa07e211 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -18,8 +18,8 @@ class Steam /** * * @param \FireflyIII\Models\Account $account - * @param \Carbon\Carbon $date - * @param bool $ignoreVirtualBalance + * @param \Carbon\Carbon $date + * @param bool $ignoreVirtualBalance * * @return float */ diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index aa56a310c0..bb63d656c4 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -39,6 +39,7 @@ class Journal extends Twig_Extension if ($type == 'Opening balance') { return ''; } + return ''; }, ['is_safe' => ['html']] From e0beb796ad2fdd1f5244d67e59b93f565b70b62f Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 13:03:04 +0200 Subject: [PATCH 03/14] Some cleaning up [skip ci] --- app/Http/Controllers/BillController.php | 1 - app/Repositories/Account/AccountRepository.php | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 8b21054389..d525a1094f 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -4,7 +4,6 @@ use Config; use FireflyIII\Http\Requests; use FireflyIII\Http\Requests\BillFormRequest; use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; use FireflyIII\Models\Bill; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index a3e98bfd57..c354c10ea1 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -16,6 +16,7 @@ use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Query\Builder; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; use Log; @@ -287,7 +288,7 @@ class AccountRepository implements AccountRepositoryInterface public function getTransfersInRange(Account $account, Carbon $start, Carbon $end) { return TransactionJournal::whereIn( - 'id', function ($q) use ($account, $start, $end) { + 'id', function (Builder $q) use ($account, $start, $end) { $q->select('transaction_journals.id') ->from('transactions') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') From 69ad757e8b2a3066952125bb3786080eb0ec5657 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 13:03:39 +0200 Subject: [PATCH 04/14] Lazily remove todo's [skip ci] --- app/Http/Controllers/TagController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 34d7364663..77a5daf1f8 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -22,10 +22,10 @@ use View; * Remember: a balancingAct takes at most one expense and one transfer. * an advancePayment takes at most one expense, infinite deposits and NO transfers. * - * TODO transaction can only have one advancePayment OR balancingAct. - * TODO Other attempts to put in such a tag are blocked. - * TODO also show an error when editing a tag and it becomes either - * TODO of these two types. Or rather, block editing of the tag. + * transaction can only have one advancePayment OR balancingAct. + * Other attempts to put in such a tag are blocked. + * also show an error when editing a tag and it becomes either + * of these two types. Or rather, block editing of the tag. * * @package FireflyIII\Http\Controllers */ From f54f1611b5040bc40bb8efe61b8d6fa0d1024cee Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 20:46:13 +0200 Subject: [PATCH 05/14] First tests for account repository. --- .env.testing | 4 +- .../Account/AccountRepository.php | 1 + pu.sh | 2 +- tests/repositories/AccountRepositoryTest.php | 406 ++++++++++++++++++ 4 files changed, 410 insertions(+), 3 deletions(-) create mode 100644 tests/repositories/AccountRepositoryTest.php diff --git a/.env.testing b/.env.testing index 1a6022cbcf..789c5a2b02 100644 --- a/.env.testing +++ b/.env.testing @@ -8,8 +8,8 @@ DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret -CACHE_DRIVER=file -SESSION_DRIVER=file +CACHE_DRIVER=array +SESSION_DRIVER=array EMAIL_SMTP= EMAIL_USERNAME= diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index c354c10ea1..a6ab2ab782 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -23,6 +23,7 @@ use Log; use Session; use Steam; + /** * Class AccountRepository * diff --git a/pu.sh b/pu.sh index cbd5c6fbf3..714a38b315 100755 --- a/pu.sh +++ b/pu.sh @@ -11,7 +11,7 @@ fi if [ ! -z "$1" ] then - phpunit --verbose tests/controllers/$1.php + phpunit --verbose tests/repositories/$1.php fi # restore .env file diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php new file mode 100644 index 0000000000..3407892ae6 --- /dev/null +++ b/tests/repositories/AccountRepositoryTest.php @@ -0,0 +1,406 @@ +object = new AccountRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + parent::tearDown(); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::countAccounts + * @todo Implement testCountAccounts(). + */ + public function testCountAccounts() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $type = $account->accountType->type; + $this->be($account->user); + + $this->assertEquals(1, $this->object->countAccounts([$type])); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::destroy + */ + public function testDestroy() + { + // create account: + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $id = $account->id; + $this->be($account->user); + + + $this->object->destroy($account); + + // cannot find account: + $this->assertCount(0, Account::whereId($id)->whereNotNull('deleted_at')->get()); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getAccounts + */ + public function testGetAccounts() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $type = $account->accountType->type; + $this->be($account->user); + + $this->assertCount(1, $this->object->getAccounts([$type])); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getCreditCards + * @todo Implement testGetCreditCards(). + */ + public function testGetCreditCards() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + + // create account meta object: + $meta = new AccountMeta; + $meta->name = 'accountRole'; + $meta->data = 'ccAsset'; + $meta->account_id = $account->id; + $meta->save(); + + // meta account type + $meta = new AccountMeta; + $meta->name = 'ccType'; + $meta->data = 'monthlyFull'; + $meta->account_id = $account->id; + $meta->save(); + + // login + $this->be($account->user); + + // test! + $this->assertCount(1, $this->object->getCreditCards()); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getFirstTransaction + * @todo Implement testGetFirstTransaction(). + */ + public function testGetFirstTransaction() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + + // two matching transactions: + $first = Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 100, + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal->id, + 'amount' => -100, + ] + ); + + // login + $this->be($account->user); + + $oldest = $this->object->getFirstTransaction($journal, $account); + + $this->assertEquals($oldest->amount, $first->amount); + $this->assertEquals($oldest->id, $first->id); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageAccounts + */ + public function testGetFrontpageAccounts() + { + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + + + // making two account types is kind of cheating but it works. + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + /** @var Preference $preference */ + $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); + $preference->data = []; + $preference->save(); + $this->be($account->user); + + $set = $this->object->getFrontpageAccounts($preference); + + $this->assertEquals($account->id, $set->first()->id); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageAccounts + * @todo Implement testGetFrontpageAccounts(). + */ + public function testGetFrontpageAccountsWithPreference() + { + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + + + // making two account types is kind of cheating but it works. + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + /** @var Preference $preference */ + $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); + $preference->data = [$account->id]; + $preference->save(); + $this->be($account->user); + + $set = $this->object->getFrontpageAccounts($preference); + + $this->assertEquals($account->id, $set->first()->id); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageTransactions + */ + public function testGetFrontpageTransactions() + { + // three journals + /** @var Account $account */ + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal3 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + + // three dates (one is out of bounds) + $journal1->date = new Carbon('2012-01-02'); + $journal1->user_id = $account->user_id; + $journal2->date = new Carbon('2012-01-09'); + $journal2->user_id = $account->user_id; + $journal3->date = new Carbon('2012-02-02'); + $journal3->user_id = $account->user_id; + + // save all + $journal1->save(); + $journal2->save(); + $journal3->save(); + + // transactions to match the dates (one per journal will do) + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal1->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal2->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal3->id, + 'amount' => 100 + ] + ); + + // be user + $this->be($journal1->user); + + // get set: + + $set = $this->object->getFrontpageTransactions($account, new Carbon('2012-01-01'), new Carbon('2012-01-31')); + + // should have two left. + $this->assertCount(2, $set); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getJournals + */ + public function testGetJournals() + { + $date = new Carbon; + // three journals + /** @var Account $account */ + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal3 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + + // three dates (one is out of bounds) + $journal1->date = $date; + $journal1->user_id = $account->user_id; + $journal2->date = $date; + $journal2->user_id = $account->user_id; + $journal3->date = $date; + $journal3->user_id = $account->user_id; + + // save all + $journal1->save(); + $journal2->save(); + $journal3->save(); + + // transactions to match the dates (one per journal will do) + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal1->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal2->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal3->id, + 'amount' => 100 + ] + ); + + // be user + $this->be($journal1->user); + + // get paginator: + /** @var LengthAwarePaginator $paginator */ + $paginator = $this->object->getJournals($account, 1); + + // should have three entries: + $this->assertEquals(3, $paginator->count()); + $this->assertEquals(1, $paginator->currentPage()); + $this->assertFalse($paginator->isEmpty()); + + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getLastActivity + * @todo Implement testGetLastActivity(). + */ + public function testGetLastActivity() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getPiggyBankAccounts + * @todo Implement testGetPiggyBankAccounts(). + */ + public function testGetPiggyBankAccounts() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts + * @todo Implement testGetSavingsAccounts(). + */ + public function testGetSavingsAccounts() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getTransfersInRange + * @todo Implement testGetTransfersInRange(). + */ + public function testGetTransfersInRange() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::leftOnAccount + * @todo Implement testLeftOnAccount(). + */ + public function testLeftOnAccount() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction + * @todo Implement testOpeningBalanceTransaction(). + */ + public function testOpeningBalanceTransaction() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::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.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::sumOfEverything + * @todo Implement testSumOfEverything(). + */ + public function testSumOfEverything() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete('This test has not been implemented yet.'); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::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.'); + } +} From 96d06b7a938ac98a5da430e11a49bfaef705d18d Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 5 May 2015 22:46:28 +0200 Subject: [PATCH 06/14] Added incomplete tests. --- tests/repositories/BudgetRepositoryTest.php | 271 ++++++++++++++++++ tests/repositories/CategoryRepositoryTest.php | 175 +++++++++++ tests/repositories/CurrencyRepositoryTest.php | 91 ++++++ tests/repositories/JournalRepositoryTest.php | 175 +++++++++++ .../repositories/PiggyBankRepositoryTest.php | 163 +++++++++++ tests/repositories/ReminderRepositoryTest.php | 79 +++++ tests/repositories/TagRepositoryTest.php | 91 ++++++ 7 files changed, 1045 insertions(+) create mode 100644 tests/repositories/BudgetRepositoryTest.php create mode 100644 tests/repositories/CategoryRepositoryTest.php create mode 100644 tests/repositories/CurrencyRepositoryTest.php create mode 100644 tests/repositories/JournalRepositoryTest.php create mode 100644 tests/repositories/PiggyBankRepositoryTest.php create mode 100644 tests/repositories/ReminderRepositoryTest.php create mode 100644 tests/repositories/TagRepositoryTest.php diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.php new file mode 100644 index 0000000000..5ae8641b39 --- /dev/null +++ b/tests/repositories/BudgetRepositoryTest.php @@ -0,0 +1,271 @@ +object = new BudgetRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\Budget\BudgetRepository::cleanupBudgets + * @todo Implement testCleanupBudgets(). + */ + public function testCleanupBudgets() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Budget\BudgetRepository::destroy + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Budget\BudgetRepository::expensesOnDay + * @todo Implement testExpensesOnDay(). + */ + public function testExpensesOnDay() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } +} diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.php new file mode 100644 index 0000000000..b17a838fdc --- /dev/null +++ b/tests/repositories/CategoryRepositoryTest.php @@ -0,0 +1,175 @@ +object = new CategoryRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\Category\CategoryRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\Category\CategoryRepository::destroy + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } +} diff --git a/tests/repositories/CurrencyRepositoryTest.php b/tests/repositories/CurrencyRepositoryTest.php new file mode 100644 index 0000000000..650b1a16b0 --- /dev/null +++ b/tests/repositories/CurrencyRepositoryTest.php @@ -0,0 +1,91 @@ +object = new CurrencyRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } + + /** + * @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.' + ); + } +} diff --git a/tests/repositories/JournalRepositoryTest.php b/tests/repositories/JournalRepositoryTest.php new file mode 100644 index 0000000000..0db59abc60 --- /dev/null +++ b/tests/repositories/JournalRepositoryTest.php @@ -0,0 +1,175 @@ +object = new JournalRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::deactivateReminder + * @todo Implement testDeactivateReminder(). + */ + public function testDeactivateReminder() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::delete + * @todo Implement testDelete(). + */ + public function testDelete() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::first + * @todo Implement testFirst(). + */ + public function testFirst() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore + * @todo Implement testGetAmountBefore(). + */ + public function testGetAmountBefore() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfType + * @todo Implement testGetJournalsOfType(). + */ + public function testGetJournalsOfType() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfTypes + * @todo Implement testGetJournalsOfTypes(). + */ + public function testGetJournalsOfTypes() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::getTransactionType + * @todo Implement testGetTransactionType(). + */ + public function testGetTransactionType() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::getWithDate + * @todo Implement testGetWithDate(). + */ + public function testGetWithDate() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::saveTags + * @todo Implement testSaveTags(). + */ + public function testSaveTags() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags + * @todo Implement testUpdateTags(). + */ + public function testUpdateTags() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/repositories/PiggyBankRepositoryTest.php b/tests/repositories/PiggyBankRepositoryTest.php new file mode 100644 index 0000000000..8dcf8e0864 --- /dev/null +++ b/tests/repositories/PiggyBankRepositoryTest.php @@ -0,0 +1,163 @@ +object = new PiggyBankRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::calculateParts + * @todo Implement testCalculateParts(). + */ + public function testCalculateParts() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createEvent + * @todo Implement testCreateEvent(). + */ + public function testCreateEvent() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createPiggyBankPart + * @todo Implement testCreatePiggyBankPart(). + */ + public function testCreatePiggyBankPart() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::destroy + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEventSummarySet + * @todo Implement testGetEventSummarySet(). + */ + public function testGetEventSummarySet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEvents + * @todo Implement testGetEvents(). + */ + public function testGetEvents() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getPiggyBanks + * @todo Implement testGetPiggyBanks(). + */ + public function testGetPiggyBanks() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::reset + * @todo Implement testReset(). + */ + public function testReset() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::setOrder + * @todo Implement testSetOrder(). + */ + public function testSetOrder() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::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.' + ); + } +} diff --git a/tests/repositories/ReminderRepositoryTest.php b/tests/repositories/ReminderRepositoryTest.php new file mode 100644 index 0000000000..2a7e96652c --- /dev/null +++ b/tests/repositories/ReminderRepositoryTest.php @@ -0,0 +1,79 @@ +object = new ReminderRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\Reminder\ReminderRepository::getActiveReminders + * @todo Implement testGetActiveReminders(). + */ + public function testGetActiveReminders() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Reminder\ReminderRepository::getDismissedReminders + * @todo Implement testGetDismissedReminders(). + */ + public function testGetDismissedReminders() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Reminder\ReminderRepository::getExpiredReminders + * @todo Implement testGetExpiredReminders(). + */ + public function testGetExpiredReminders() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Reminder\ReminderRepository::getInactiveReminders + * @todo Implement testGetInactiveReminders(). + */ + public function testGetInactiveReminders() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.php new file mode 100644 index 0000000000..36b023ba7b --- /dev/null +++ b/tests/repositories/TagRepositoryTest.php @@ -0,0 +1,91 @@ +object = new TagRepository; + parent::setUp(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + } + + /** + * @covers FireflyIII\Repositories\Tag\TagRepository::connect + * @todo Implement testConnect(). + */ + public function testConnect() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Tag\TagRepository::destroy + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FireflyIII\Repositories\Tag\TagRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\Tag\TagRepository::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.' + ); + } + + /** + * @covers FireflyIII\Repositories\Tag\TagRepository::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.' + ); + } +} From 2b6b896c2ec982c008215517b318adbe039f004d Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 6 May 2015 18:09:45 +0200 Subject: [PATCH 07/14] Some more coverage. --- app/Models/PiggyBankRepetition.php | 2 + .../Account/AccountRepository.php | 2 +- tests/factories/all.php | 13 +++ tests/repositories/AccountRepositoryTest.php | 80 +++++++++++++++++-- tests/repositories/BudgetRepositoryTest.php | 1 + tests/repositories/CategoryRepositoryTest.php | 1 + tests/repositories/CurrencyRepositoryTest.php | 1 + tests/repositories/JournalRepositoryTest.php | 1 + .../repositories/PiggyBankRepositoryTest.php | 1 + tests/repositories/ReminderRepositoryTest.php | 1 + tests/repositories/TagRepositoryTest.php | 1 + 11 files changed, 97 insertions(+), 7 deletions(-) diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 6c5c939b16..07202b672e 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -12,6 +12,8 @@ use Illuminate\Database\Eloquent\Model; class PiggyBankRepetition extends Model { + protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount']; + /** * @return array */ diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index a6ab2ab782..9825b5cd0c 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -226,7 +226,7 @@ class AccountRepository implements AccountRepositoryInterface // then, percentage. $difference = $account->endBalance - $account->piggyBalance; $account->difference = $difference; - $account->percentage = $difference != 0 ? round((($difference / $account->endBalance) * 100)) : 100; + $account->percentage = $difference != 0 && $account->endBalance != 0 ? round((($difference / $account->endBalance) * 100)) : 100; } ); diff --git a/tests/factories/all.php b/tests/factories/all.php index 07a1c1f529..33c2577c03 100644 --- a/tests/factories/all.php +++ b/tests/factories/all.php @@ -227,6 +227,19 @@ FactoryMuffin::define( ] ); +FactoryMuffin::define( + 'FireflyIII\Models\PiggyBankRepetition', + [ + 'piggy_bank_id' => 'factory|FireflyIII\Models\PiggyBank', + 'startdate' => 'date', + 'targetdate' => 'date', + 'currentamount' => function () { + return rand(1, 100); + }, + ] +); + + FactoryMuffin::define( 'FireflyIII\Models\PiggyBankEvent', [ diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index 3407892ae6..e739da0d63 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -2,6 +2,7 @@ use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; +use FireflyIII\Models\PiggyBankRepetition; use FireflyIII\Models\Preference; use FireflyIII\Models\Transaction; use FireflyIII\Repositories\Account\AccountRepository; @@ -169,7 +170,6 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageAccounts - * @todo Implement testGetFrontpageAccounts(). */ public function testGetFrontpageAccountsWithPreference() { @@ -316,12 +316,49 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::getLastActivity - * @todo Implement testGetLastActivity(). */ public function testGetLastActivity() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + $date = new Carbon('2012-02-02'); + // one journals + /** @var Account $account */ + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal->date = $date; + $journal->user_id = $account->user_id; + $journal->save(); + + // transaction to match the date (one will do) + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 100 + ] + ); + + // be user + $this->be($journal->user); + + $latest = $this->object->getLastActivity($account); + $this->assertEquals($date->format('Y-m-d'), $latest->format('Y-m-d')); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::getLastActivity + */ + public function testGetLastActivityNoActivity() + { + $date = new Carbon('2012-02-02'); + // one journals + /** @var Account $account */ + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $this->be($account->user); + + $latest = $this->object->getLastActivity($account); + $this->assertnull($latest); + } /** @@ -330,8 +367,39 @@ class AccountRepositoryTest extends TestCase */ public function testGetPiggyBankAccounts() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + $date = Carbon::now()->startOfMonth()->addDays(3); + /* + * Quite the collection of objects for this one. + */ + $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $piggyBankRepetition = $piggyBank->piggybankRepetitions()->first(); + /* + * Update id's to match each other: + */ + $piggyBankRepetition->currentamount = rand(1,100); + $piggyBankRepetition->startdate = $date; + $piggyBankRepetition->targetdate = $date; + $piggyBank->account_id = $account->id; + $piggyBankRepetition->save(); + $piggyBank->save(); + + /* + * Put dates in session: + */ + $this->session(['start' => Carbon::now()->startOfMonth(), 'end' => Carbon::now()->endOfMonth()]); + + /* + * Run method: + */ + $this->be($account->user); + $collection = $this->object->getPiggyBankAccounts(); + + $this->assertCount(1, $collection); + $this->assertEquals($collection->first()->id, $account->id); + $this->assertEquals($collection->first()->piggyBalance, $piggyBankRepetition->currentamount); + $this->assertEquals(0, $collection->first()->startBalance); + $this->assertEquals(0, $collection->first()->endBalance); } /** diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.php index 5ae8641b39..5eb3ce86d3 100644 --- a/tests/repositories/BudgetRepositoryTest.php +++ b/tests/repositories/BudgetRepositoryTest.php @@ -27,6 +27,7 @@ class BudgetRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.php index b17a838fdc..e5288656c4 100644 --- a/tests/repositories/CategoryRepositoryTest.php +++ b/tests/repositories/CategoryRepositoryTest.php @@ -27,6 +27,7 @@ class CategoryRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/CurrencyRepositoryTest.php b/tests/repositories/CurrencyRepositoryTest.php index 650b1a16b0..756991dd3d 100644 --- a/tests/repositories/CurrencyRepositoryTest.php +++ b/tests/repositories/CurrencyRepositoryTest.php @@ -27,6 +27,7 @@ class CurrencyRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/JournalRepositoryTest.php b/tests/repositories/JournalRepositoryTest.php index 0db59abc60..69840beaef 100644 --- a/tests/repositories/JournalRepositoryTest.php +++ b/tests/repositories/JournalRepositoryTest.php @@ -27,6 +27,7 @@ class JournalRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/PiggyBankRepositoryTest.php b/tests/repositories/PiggyBankRepositoryTest.php index 8dcf8e0864..acbb997467 100644 --- a/tests/repositories/PiggyBankRepositoryTest.php +++ b/tests/repositories/PiggyBankRepositoryTest.php @@ -27,6 +27,7 @@ class PiggyBankRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/ReminderRepositoryTest.php b/tests/repositories/ReminderRepositoryTest.php index 2a7e96652c..c0a5a2a39d 100644 --- a/tests/repositories/ReminderRepositoryTest.php +++ b/tests/repositories/ReminderRepositoryTest.php @@ -27,6 +27,7 @@ class ReminderRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.php index 36b023ba7b..fb1b57cd0c 100644 --- a/tests/repositories/TagRepositoryTest.php +++ b/tests/repositories/TagRepositoryTest.php @@ -27,6 +27,7 @@ class TagRepositoryTest extends TestCase */ public function tearDown() { + parent::tearDown(); } /** From 184e8b1132d467ca04f9e94b9f643d59ead6d5ab Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 7 May 2015 20:56:27 +0200 Subject: [PATCH 08/14] Some new tests. --- .../Account/AccountRepository.php | 1 + tests/repositories/AccountRepositoryTest.php | 65 +++++++++++++++++-- tests/repositories/ReminderRepositoryTest.php | 3 +- 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9825b5cd0c..b624229355 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -271,6 +271,7 @@ class AccountRepository implements AccountRepositoryInterface $pct = $pct > 100 ? 100 : $pct; $account->difference = $diff; $account->percentage = round($pct); + } ); diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index e739da0d63..ec92023a10 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -2,6 +2,7 @@ use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; +use FireflyIII\Models\AccountType; use FireflyIII\Models\PiggyBankRepetition; use FireflyIII\Models\Preference; use FireflyIII\Models\Transaction; @@ -363,7 +364,6 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::getPiggyBankAccounts - * @todo Implement testGetPiggyBankAccounts(). */ public function testGetPiggyBankAccounts() { @@ -377,7 +377,7 @@ class AccountRepositoryTest extends TestCase /* * Update id's to match each other: */ - $piggyBankRepetition->currentamount = rand(1,100); + $piggyBankRepetition->currentamount = rand(1, 100); $piggyBankRepetition->startdate = $date; $piggyBankRepetition->targetdate = $date; $piggyBank->account_id = $account->id; @@ -404,12 +404,60 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts - * @todo Implement testGetSavingsAccounts(). */ public function testGetSavingsAccounts() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + // create three accounts: + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + $type = FactoryMuffin::create('FireflyIII\Models\AccountType'); + $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); + $account1->account_type_id = $type->id; + $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); + $account2->account_type_id = $type->id; + $account3 = FactoryMuffin::create('FireflyIII\Models\Account'); + $account3->account_type_id = $type->id; + + // make them savings accounts: + $meta = new AccountMeta; + $meta->name = 'accountRole'; + $meta->data = 'savingAsset'; + $meta->account_id = $account1->id; + $meta->save(); + + $meta = new AccountMeta; + $meta->name = 'accountRole'; + $meta->data = 'savingAsset'; + $meta->account_id = $account2->id; + $meta->save(); + + $meta = new AccountMeta; + $meta->name = 'accountRole'; + $meta->data = 'savingAsset'; + $meta->account_id = $account3->id; + $meta->save(); + + // assign to the same user: + $account2->user_id = $account1->user_id; + $account3->user_id = $account1->user_id; + $account1->save(); + $account2->save(); + $account3->save(); + $this->be($account1->user); + + // mock steam balance: + Steam::shouldReceive('balance')->andReturn(0, 0, 1, 2, 4, 3); + + // get the result from the method: + $result = $this->object->getSavingsAccounts(); + + $this->assertEquals(0, $result->get(0)->difference); + $this->assertEquals(1, $result->get(1)->difference); + $this->assertEquals(-1, $result->get(2)->difference); + + $this->assertEquals(100, $result->get(0)->percentage); + $this->assertEquals(100, $result->get(1)->percentage); + $this->assertEquals(25, $result->get(2)->percentage); } /** @@ -418,6 +466,13 @@ class AccountRepositoryTest extends TestCase */ public function testGetTransfersInRange() { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + + $date = new Carbon; + + // three transfers, two out of range: + + // Remove the following lines when you implement this test. $this->markTestIncomplete('This test has not been implemented yet.'); } diff --git a/tests/repositories/ReminderRepositoryTest.php b/tests/repositories/ReminderRepositoryTest.php index c0a5a2a39d..55e5277577 100644 --- a/tests/repositories/ReminderRepositoryTest.php +++ b/tests/repositories/ReminderRepositoryTest.php @@ -17,8 +17,9 @@ class ReminderRepositoryTest extends TestCase */ public function setUp() { - $this->object = new ReminderRepository; parent::setUp(); + $this->object = new ReminderRepository; + } /** From 5a98a5252d5846fb800ea024ecf2f868da472484 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 7 May 2015 21:26:00 +0200 Subject: [PATCH 09/14] Added tests. --- .../Account/AccountRepository.php | 2 +- tests/repositories/AccountRepositoryTest.php | 77 +++++++++++++++++-- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index b624229355..9504907c72 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -313,7 +313,7 @@ class AccountRepository implements AccountRepositoryInterface */ public function leftOnAccount(Account $account) { - $balance = \Steam::balance($account, null, true); + $balance = Steam::balance($account, null, true); /** @var PiggyBank $p */ foreach ($account->piggybanks()->get() as $p) { $balance -= $p->currentRelevantRep()->currentamount; diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index ec92023a10..88838fa3cf 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -113,7 +113,6 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::getFirstTransaction - * @todo Implement testGetFirstTransaction(). */ public function testGetFirstTransaction() { @@ -321,7 +320,7 @@ class AccountRepositoryTest extends TestCase public function testGetLastActivity() { $date = new Carbon('2012-02-02'); - // one journals + // one journal /** @var Account $account */ $account = FactoryMuffin::create('FireflyIII\Models\Account'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); @@ -351,8 +350,6 @@ class AccountRepositoryTest extends TestCase */ public function testGetLastActivityNoActivity() { - $date = new Carbon('2012-02-02'); - // one journals /** @var Account $account */ $account = FactoryMuffin::create('FireflyIII\Models\Account'); $this->be($account->user); @@ -471,10 +468,64 @@ class AccountRepositoryTest extends TestCase $date = new Carbon; // three transfers, two out of range: + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal3 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal2->transaction_type_id = $journal1->transaction_type_id; + $journal3->transaction_type_id = $journal1->transaction_type_id; + + // three transactions: + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal1->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal2->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal3->id, + 'amount' => 100 + ] + ); + + // check date: + $start = new Carbon('2014-01-01'); + $end = new Carbon('2014-01-31'); + $inRange = new Carbon('2014-01-15'); + $before = new Carbon('2013-01-15'); + $after = new Carbon('2015-01-15'); + + // journal 1 will match: + $journal1->date = $inRange; + $journal1->user_id = $account->user_id; + $journal2->date = $before; + $journal2->user_id = $account->user_id; + $journal3->date = $after; + $journal3->user_id = $account->user_id; + $journal1->save(); + $journal2->save(); + $journal3->save(); + $this->be($account->user); + + $set = $this->object->getTransfersInRange($account, $start, $end); - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + $this->assertEquals(1, $set->count()); + $this->assertEquals(100, $set->first()->amount); + $this->assertEquals($journal1->description, $set->first()->description); + } /** @@ -483,8 +534,18 @@ class AccountRepositoryTest extends TestCase */ public function testLeftOnAccount() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); + $piggyBankRepetition = $piggyBank->piggybankRepetitions()->first(); + $piggyBankRepetition->currentamount = rand(1, 100); + $piggyBankRepetition->save(); + $this->be($piggyBank->account->user); + + + $result = $this->object->leftOnAccount($piggyBank->account); + + $this->assertEquals($piggyBankRepetition->currentamount * -1, $result); + + } /** From cc015920854293d7583734b2602fb4e4427bae31 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 8 May 2015 06:01:39 +0200 Subject: [PATCH 10/14] Cover some more account repository. --- tests/repositories/AccountRepositoryTest.php | 84 ++++++++++++++++++-- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index 88838fa3cf..43ec9fa1c0 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -530,7 +530,6 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::leftOnAccount - * @todo Implement testLeftOnAccount(). */ public function testLeftOnAccount() { @@ -550,22 +549,93 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction - * @todo Implement testOpeningBalanceTransaction(). */ public function testOpeningBalanceTransaction() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete('This test has not been implemented yet.'); + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + // two transactions: + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal1->id, + 'amount' => 100 + ] + ); + Transaction::create( + [ + 'account_id' => $account->id, + 'transaction_journal_id' => $journal2->id, + 'amount' => 100 + ] + ); + + // dates + $one = new Carbon('2013-01-15'); + $two = new Carbon('2015-01-15'); + + // journal 1 will match: + $journal1->date = $one; + $journal1->user_id = $account->user_id; + $journal2->date = $two; + $journal2->user_id = $account->user_id; + $journal1->save(); + $journal2->save(); + + + $this->be($account->user); + + $result = $this->object->openingBalanceTransaction($account); + $this->assertEquals($journal1->id, $result->id); + $this->assertEquals($journal1->description, $result->description); + $this->assertEquals(100, $result->amount); + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction + */ + public function testOpeningBalanceTransactionNull() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $this->be($account->user); + + $result = $this->object->openingBalanceTransaction($account); + $this->assertNull($result); } /** * @covers FireflyIII\Repositories\Account\AccountRepository::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'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); + $this->be($user); + + $data = [ + 'accountType' => 'expense', + 'user' => $user->id, + 'name' => 'Test account #' . rand(1, 100), + 'active' => true, + 'accountRole' => 'testAccount', + 'openingBalance' => 100, + 'virtualBalance' => 0, + 'openingBalanceCurrency' => $currency->id, + 'openingBalanceDate' => '2015-01-01', + ]; + + + $account = $this->object->store($data); + + $this->assertEquals($data['name'], $account->name); + } /** From cefbbcd1dfeac710ba3c1c21f52b44b03732c2d5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 8 May 2015 07:27:29 +0200 Subject: [PATCH 11/14] Fixed some tests. --- app/Models/Account.php | 25 ++++ .../Account/AccountRepository.php | 8 +- tests/factories/all.php | 4 +- tests/repositories/AccountRepositoryTest.php | 122 +++++++++++++++++- 4 files changed, 153 insertions(+), 6 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 77c8a66086..dcea8ec26e 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -60,6 +60,31 @@ class Account extends Model } + /** + * @param array $fields + * + * @return Account|null + */ + public static function firstOrNullEncrypted(array $fields) + { + // everything but the name: + $query = Account::orderBy('id'); + foreach ($fields as $name => $value) { + if ($name != 'name') { + $query->where($name, $value); + } + } + $set = $query->get(['accounts.*']); + /** @var Account $account */ + foreach ($set as $account) { + if ($account->name == $fields['name']) { + return $account; + } + } + + return null; + } + /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9504907c72..456754492e 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -443,11 +443,15 @@ class AccountRepository implements AccountRepositoryInterface if (!$newAccount->isValid()) { // does the account already exist? - $existingAccount = Account::where('user_id', $data['user'])->where('account_type_id', $accountType->id)->where('name', $data['name'])->first(); + $searchData = [ + 'user_id' => $data['user'], + 'account_type_id' => $accountType->id, + 'name' => $data['name'] + ]; + $existingAccount = Account::firstOrNullEncrypted($searchData); if (!$existingAccount) { Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); App::abort(500); - } $newAccount = $existingAccount; } diff --git a/tests/factories/all.php b/tests/factories/all.php index 33c2577c03..4b9075a7cd 100644 --- a/tests/factories/all.php +++ b/tests/factories/all.php @@ -61,7 +61,9 @@ FactoryMuffin::define( 'account_type_id' => 'factory|FireflyIII\Models\AccountType', 'name' => 'word', 'active' => 'boolean', - 'encrypted' => 'boolean', + 'encrypted' => function () { + return true; + }, 'virtual_balance' => 0 ] ); diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index 43ec9fa1c0..03319f2b65 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -606,6 +606,9 @@ class AccountRepositoryTest extends TestCase /** * @covers FireflyIII\Repositories\Account\AccountRepository::store + * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount + * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata + * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance */ public function testStore() { @@ -638,14 +641,127 @@ class AccountRepositoryTest extends TestCase } + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::store + * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount + * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata + * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance + */ + public function testStoreWithNegativeInitialBalance() + { + $user = FactoryMuffin::create('FireflyIII\User'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); + $this->be($user); + + $data = [ + 'accountType' => 'expense', + 'user' => $user->id, + 'name' => 'Test account #' . rand(1, 100), + 'active' => true, + 'accountRole' => 'testAccount', + 'openingBalance' => -100, + 'virtualBalance' => 0, + 'openingBalanceCurrency' => $currency->id, + 'openingBalanceDate' => '2015-01-01', + ]; + + + $account = $this->object->store($data); + + $this->assertEquals($data['name'], $account->name); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::store + * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount + * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata + * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance + */ + public function testStoreWithExistingAccount() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); + $this->be($account->user); + + + $data = [ + 'accountType' => 'expense', + 'user' => $account->user->id, + 'name' => $account->name, + 'active' => $account->active, + 'accountRole' => 'testAccount', + 'openingBalance' => 0, + 'virtualBalance' => 0, + 'openingBalanceCurrency' => $currency->id, + 'openingBalanceDate' => '2015-01-01', + ]; + + + $newAccount = $this->object->store($data); + + $this->assertEquals($account->name, $newAccount->name); + $this->assertEquals($account->id, $newAccount->id); + + } + + /** + * @covers FireflyIII\Repositories\Account\AccountRepository::store + * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount + * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata + * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance + */ + public function testStoreWithInvalidAccountData() + { + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $this->be($account->user); + + + $data = [ + 'accountType' => 'expense', + 'user' => $account->user->id, + 'name' => $account->name, + 'active' => $account->active, + 'accountRole' => 'testAccount', + 'openingBalance' => 0, + 'virtualBalance' => 0, + 'openingBalanceCurrency' => 12, + 'openingBalanceDate' => '2015-01-01', + ]; + + + $newAccount = $this->object->store($data); + + $this->assertEquals($account->name, $newAccount->name); + $this->assertEquals($account->id, $newAccount->id); + + } + /** * @covers FireflyIII\Repositories\Account\AccountRepository::sumOfEverything - * @todo Implement testSumOfEverything(). */ public function testSumOfEverything() { - // 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); + + $this->assertEquals(0, $this->object->sumOfEverything()); } /** From 54195c0826703373e49d545d00bcc6069d06d502 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 8 May 2015 07:39:05 +0200 Subject: [PATCH 12/14] Updated tests. --- app/Repositories/Account/AccountRepository.php | 3 +++ tests/repositories/AccountRepositoryTest.php | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 456754492e..c026a037d0 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -452,8 +452,11 @@ class AccountRepository implements AccountRepositoryInterface if (!$existingAccount) { Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); App::abort(500); + // @codeCoverageIgnoreStart } + // @codeCoverageIgnoreEnd $newAccount = $existingAccount; + } $newAccount->save(); diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php index 03319f2b65..d635463355 100644 --- a/tests/repositories/AccountRepositoryTest.php +++ b/tests/repositories/AccountRepositoryTest.php @@ -721,6 +721,7 @@ class AccountRepositoryTest extends TestCase * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance + * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testStoreWithInvalidAccountData() { @@ -730,26 +731,23 @@ class AccountRepositoryTest extends TestCase FactoryMuffin::create('FireflyIII\Models\TransactionType'); FactoryMuffin::create('FireflyIII\Models\TransactionType'); FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); $this->be($account->user); $data = [ 'accountType' => 'expense', - 'user' => $account->user->id, + 'user' => $account->user->id + 12, 'name' => $account->name, 'active' => $account->active, 'accountRole' => 'testAccount', 'openingBalance' => 0, 'virtualBalance' => 0, - 'openingBalanceCurrency' => 12, + 'openingBalanceCurrency' => $currency->id, 'openingBalanceDate' => '2015-01-01', ]; - - $newAccount = $this->object->store($data); - - $this->assertEquals($account->name, $newAccount->name); - $this->assertEquals($account->id, $newAccount->id); + $this->object->store($data); } From ed910b99a715c8f879574bcabdfa5987f3c43bc4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 8 May 2015 07:48:04 +0200 Subject: [PATCH 13/14] Update travis configuration [skip ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee3f0642c3..81cac8830e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ install: - mv -v .env.testing .env script: - - phpunit --debug + - phpunit after_script: - php vendor/bin/coveralls From 7a2f169dfc3b7dc0106576bb7b72cf74485a8c9e Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 8 May 2015 07:56:55 +0200 Subject: [PATCH 14/14] Push new version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12f92844b6..c44c790cac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Firefly III (v3.4.0.1) +Firefly III (v3.4.0.2) =========== [![Build Status](https://travis-ci.org/JC5/firefly-iii.svg?branch=develop)](https://travis-ci.org/JC5/firefly-iii)