From 1dcf7407e60aa47fadeb418f958c2703d8170bbe Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 14 May 2015 09:51:54 +0200 Subject: [PATCH] Cleanup [skip ci] --- .../Events/ConnectJournalToPiggyBank.php | 1 + app/Helpers/Help/Help.php | 5 +++ app/Helpers/Report/ReportHelper.php | 8 ++-- app/Http/Controllers/Auth/AuthController.php | 1 + .../Controllers/Auth/PasswordController.php | 1 + app/Http/Middleware/PiggyBanks.php | 1 - app/Models/Account.php | 4 ++ app/Models/Category.php | 2 + app/Models/PiggyBank.php | 3 ++ app/Models/Reminder.php | 6 +++ app/Models/Tag.php | 4 ++ app/Models/TransactionJournal.php | 8 ++++ app/Providers/FireflyServiceProvider.php | 2 +- app/Repositories/Budget/BudgetRepository.php | 3 +- .../Journal/JournalRepository.php | 1 + .../PiggyBank/PiggyBankRepository.php | 4 +- app/Repositories/Tag/TagRepository.php | 1 + app/Support/Twig/Translation.php | 2 +- tests/controllers/AuthControllerTest.php | 4 +- tests/controllers/TagControllerTest.php | 45 +++++++++---------- tests/factories/all.php | 2 +- .../helpers/ConnectJournalToPiggyBankTest.php | 4 +- tests/helpers/ReportHelperTest.php | 12 ++--- tests/repositories/BudgetRepositoryTest.php | 4 +- tests/repositories/JournalRepositoryTest.php | 1 + tests/repositories/TagRepositoryTest.php | 2 +- 26 files changed, 84 insertions(+), 47 deletions(-) diff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.php index 1f3d2a2e70..d9a46886db 100644 --- a/app/Handlers/Events/ConnectJournalToPiggyBank.php +++ b/app/Handlers/Events/ConnectJournalToPiggyBank.php @@ -91,6 +91,7 @@ class ConnectJournalToPiggyBank 'amount' => $amount ] ); + return true; } diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index 19bab089e9..39628ea108 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -18,6 +18,7 @@ class Help implements HelpInterface /** * @codeCoverageIgnore + * * @param $key * * @return string @@ -29,6 +30,7 @@ class Help implements HelpInterface /** * @codeCoverageIgnore + * * @param $route * * @return array @@ -57,6 +59,7 @@ class Help implements HelpInterface /** * @codeCoverageIgnore + * * @param $route * * @return bool @@ -68,6 +71,7 @@ class Help implements HelpInterface /** * @codeCoverageIgnore + * * @param $route * @param array $content * @@ -81,6 +85,7 @@ class Help implements HelpInterface /** * @codeCoverageIgnore + * * @param $route * * @return bool diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index b06c6237e9..f90e22e0e2 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -118,10 +118,10 @@ class ReportHelper implements ReportHelperInterface $sharedAccounts = []; if ($showSharedReports === false) { $sharedCollection = Auth::user()->accounts() - ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id') - ->where('account_meta.name', '=', 'accountRole') - ->where('account_meta.data', '=', json_encode('sharedAsset')) - ->get(['accounts.id']); + ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id') + ->where('account_meta.name', '=', 'accountRole') + ->where('account_meta.data', '=', json_encode('sharedAsset')) + ->get(['accounts.id']); foreach ($sharedCollection as $account) { $sharedAccounts[] = $account->id; diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 27c50adb65..80301480e1 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -38,6 +38,7 @@ class AuthController extends Controller * * @param \Illuminate\Contracts\Auth\Guard $auth * @param \Illuminate\Contracts\Auth\Registrar $registrar + * * @codeCoverageIgnore * */ diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 907b514894..9648ce287d 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -7,6 +7,7 @@ use Illuminate\Foundation\Auth\ResetsPasswords; /** * Class PasswordController + * * @codeCoverageIgnore * @package FireflyIII\Http\Controllers\Auth */ diff --git a/app/Http/Middleware/PiggyBanks.php b/app/Http/Middleware/PiggyBanks.php index 810f396fce..190aa00e32 100644 --- a/app/Http/Middleware/PiggyBanks.php +++ b/app/Http/Middleware/PiggyBanks.php @@ -3,7 +3,6 @@ namespace FireflyIII\Http\Middleware; -use App; use Closure; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankRepetition; diff --git a/app/Models/Account.php b/app/Models/Account.php index e9e39346f5..d3d7b4545a 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -133,6 +133,7 @@ class Account extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string @@ -160,6 +161,7 @@ class Account extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param array $types */ @@ -174,6 +176,7 @@ class Account extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param string $name * @param string $value @@ -191,6 +194,7 @@ class Account extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setNameAttribute($value) diff --git a/app/Models/Category.php b/app/Models/Category.php index 363f773d2a..3f1e029535 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -79,6 +79,7 @@ class Category extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setNameAttribute($value) @@ -89,6 +90,7 @@ class Category extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 9879b3f1a8..f4486b99c3 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -64,6 +64,7 @@ class PiggyBank extends Model /** * @codeCoverageIgnore + * * @param $value * * @return int @@ -93,6 +94,7 @@ class PiggyBank extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setNameAttribute($value) @@ -103,6 +105,7 @@ class PiggyBank extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string diff --git a/app/Models/Reminder.php b/app/Models/Reminder.php index 0160f1a9f1..38da24deed 100644 --- a/app/Models/Reminder.php +++ b/app/Models/Reminder.php @@ -18,6 +18,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param $value * * @return int @@ -38,6 +39,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param $value * * @return mixed @@ -53,6 +55,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param $value * * @return bool @@ -73,6 +76,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param Carbon $start * @param Carbon $end @@ -86,6 +90,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * * @return $this @@ -100,6 +105,7 @@ class Reminder extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setMetadataAttribute($value) diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 286a481fc0..6312b37df9 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -77,6 +77,7 @@ class Tag extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string @@ -88,6 +89,7 @@ class Tag extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string @@ -99,6 +101,7 @@ class Tag extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setDescriptionAttribute($value) @@ -108,6 +111,7 @@ class Tag extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setTagAttribute($value) diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 7fd1e4db4c..b90726afb0 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -116,6 +116,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param $value * * @return string @@ -140,6 +141,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param Account $account */ @@ -154,6 +156,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param Carbon $date * @@ -166,6 +169,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param Carbon $date * @@ -178,6 +182,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param $amount */ @@ -195,6 +200,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param Carbon $date * @@ -207,6 +213,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param EloquentBuilder $query * @param array $types */ @@ -239,6 +246,7 @@ class TransactionJournal extends Model /** * @codeCoverageIgnore + * * @param $value */ public function setDescriptionAttribute($value) diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 066ee64665..71d2a5ba1d 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -10,9 +10,9 @@ use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Support\Twig\Budget; use FireflyIII\Support\Twig\General; -use FireflyIII\Support\Twig\Translation; use FireflyIII\Support\Twig\Journal; use FireflyIII\Support\Twig\PiggyBank; +use FireflyIII\Support\Twig\Translation; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; use Twig; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index b0e3ac5559..4a6cf2eafe 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -250,7 +250,8 @@ class BudgetRepository implements BudgetRepositoryInterface ->before($end) ->lessThan(0) ->transactionTypes(['Withdrawal']) - ->sum('transactions.amount'); + ->sum('transactions.amount'); + return floatval($noBudgetSet) * -1; } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 012a144bdb..05ed690581 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -391,6 +391,7 @@ class JournalRepository implements JournalRepositoryInterface App::abort(500, '"from"-account is null, so we cannot continue!'); // @codeCoverageIgnoreStart } + // @codeCoverageIgnoreEnd return [$from, $to]; diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 6fe50edd23..a7f9a06dfa 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -151,8 +151,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface { // split query to make it work in sqlite: $set = PiggyBank:: - leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id') - ->where('accounts.user_id', Auth::user()->id)->get(['piggy_banks.*']); + leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id') + ->where('accounts.user_id', Auth::user()->id)->get(['piggy_banks.*']); foreach ($set as $e) { $e->order = 0; $e->save(); diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 4f27c7f9d9..3eea380e07 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -111,6 +111,7 @@ class TagRepository implements TagRepositoryInterface return false; } + // @codeCoverageIgnoreStart return false; } diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php index 3bfd795420..3513d4ddb1 100644 --- a/app/Support/Twig/Translation.php +++ b/app/Support/Twig/Translation.php @@ -24,7 +24,7 @@ class Translation extends Twig_Extension $filters[] = new Twig_SimpleFilter( '_', function ($name) { - return trans('firefly.'.$name); + return trans('firefly.' . $name); }, ['is_safe' => ['html']] ); diff --git a/tests/controllers/AuthControllerTest.php b/tests/controllers/AuthControllerTest.php index abe9fa9e44..6806f7db4d 100644 --- a/tests/controllers/AuthControllerTest.php +++ b/tests/controllers/AuthControllerTest.php @@ -39,7 +39,7 @@ class AuthControllerTest extends TestCase public function testPostRegister() { - $data = [ + $data = [ 'email' => 'test@example.com', 'password' => 'onetwothree', 'password_confirmation' => 'onetwothree', @@ -53,7 +53,7 @@ class AuthControllerTest extends TestCase public function testPostRegisterFails() { - $data = [ + $data = [ 'email' => 'test@example.com', 'password' => 'onetwothree', 'password_confirmation' => 'onetwofour', diff --git a/tests/controllers/TagControllerTest.php b/tests/controllers/TagControllerTest.php index 1e6c65fad9..9e3a1747ac 100644 --- a/tests/controllers/TagControllerTest.php +++ b/tests/controllers/TagControllerTest.php @@ -115,29 +115,6 @@ class TagControllerTest extends TestCase $this->assertResponseOk(); } - public function testMultipleDeposits() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - for ($i = 0; $i < 3; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $type->id; - $journal->save(); - $tag->transactionJournals()->save($journal); - } - - - $tag->tagMode = 'nothing'; - $tag->save(); - $this->be($tag->user); - - $this->call('GET', '/tags/edit/' . $tag->id); - $this->assertResponseOk(); - } - - public function testHideTagHelp() { $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); @@ -156,6 +133,28 @@ class TagControllerTest extends TestCase $this->assertResponseOk(); } + public function testMultipleDeposits() + { + $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); + FactoryMuffin::create('FireflyIII\Models\TransactionType'); + $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); + + for ($i = 0; $i < 3; $i++) { + $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal->transaction_type_id = $type->id; + $journal->save(); + $tag->transactionJournals()->save($journal); + } + + + $tag->tagMode = 'nothing'; + $tag->save(); + $this->be($tag->user); + + $this->call('GET', '/tags/edit/' . $tag->id); + $this->assertResponseOk(); + } + public function testShow() { $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); diff --git a/tests/factories/all.php b/tests/factories/all.php index 572cf25ee1..0250e1bac3 100644 --- a/tests/factories/all.php +++ b/tests/factories/all.php @@ -173,7 +173,7 @@ FactoryMuffin::define( 'FireflyIII\Models\AccountType', [ 'type' => function () { - $types = ['Expense account', 'Revenue account', 'Asset account','Cash account']; + $types = ['Expense account', 'Revenue account', 'Asset account', 'Cash account']; $count = DB::table('account_types')->count(); if ($count < 4) { return $types[$count]; diff --git a/tests/helpers/ConnectJournalToPiggyBankTest.php b/tests/helpers/ConnectJournalToPiggyBankTest.php index a40e4e0130..a5bb44f568 100644 --- a/tests/helpers/ConnectJournalToPiggyBankTest.php +++ b/tests/helpers/ConnectJournalToPiggyBankTest.php @@ -49,7 +49,7 @@ class ConnectJournalToPiggyBankTest extends TestCase $user = FactoryMuffin::create('FireflyIII\User'); $this->be($user); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); + $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); /** @var \FireflyIII\Models\PiggyBank $piggyBank */ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); @@ -64,7 +64,7 @@ class ConnectJournalToPiggyBankTest extends TestCase // because the event handler responds to this piggy bank, we must remove // the piggy bank repetition: /** @var \FireflyIII\Models\PiggyBankRepetition $rep */ - foreach($piggyBank->piggyBankRepetitions()->get() as $rep) { + foreach ($piggyBank->piggyBankRepetitions()->get() as $rep) { $rep->forceDelete(); } diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.php index d11b0416ee..2d8d5e1fbb 100644 --- a/tests/helpers/ReportHelperTest.php +++ b/tests/helpers/ReportHelperTest.php @@ -130,8 +130,8 @@ class ReportHelperTest extends TestCase public function testYearBalanceReport() { - $date = new Carbon('2015-01-01'); - $user = FactoryMuffin::create('FireflyIII\User'); + $date = new Carbon('2015-01-01'); + $user = FactoryMuffin::create('FireflyIII\User'); $setShared = []; $setNormal = []; @@ -171,7 +171,7 @@ class ReportHelperTest extends TestCase $this->be($user); $result = $this->object->yearBalanceReport($date, false); - foreach($result as $entry) { + foreach ($result as $entry) { // everything is hidden: $this->assertTrue($entry['hide']); // nothing is shared: @@ -182,8 +182,8 @@ class ReportHelperTest extends TestCase public function testYearBalanceReportWithShared() { - $date = new Carbon('2015-01-01'); - $user = FactoryMuffin::create('FireflyIII\User'); + $date = new Carbon('2015-01-01'); + $user = FactoryMuffin::create('FireflyIII\User'); $setShared = []; $setNormal = []; @@ -223,7 +223,7 @@ class ReportHelperTest extends TestCase $this->be($user); $result = $this->object->yearBalanceReport($date, true); - foreach($result as $entry) { + foreach ($result as $entry) { // everything is hidden: $this->assertTrue($entry['hide']); // nothing is shared: diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.php index 104920040e..b9b9d018bc 100644 --- a/tests/repositories/BudgetRepositoryTest.php +++ b/tests/repositories/BudgetRepositoryTest.php @@ -363,7 +363,7 @@ class BudgetRepositoryTest extends TestCase */ public function testUpdateLimitAmountExisting() { - $budgetLimit= FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); + $budgetLimit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 100); @@ -376,7 +376,7 @@ class BudgetRepositoryTest extends TestCase */ public function testUpdateLimitAmountZero() { - $budgetLimit= FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); + $budgetLimit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 0); diff --git a/tests/repositories/JournalRepositoryTest.php b/tests/repositories/JournalRepositoryTest.php index e4d0e2a68a..2206bbeee8 100644 --- a/tests/repositories/JournalRepositoryTest.php +++ b/tests/repositories/JournalRepositoryTest.php @@ -478,6 +478,7 @@ class JournalRepositoryTest extends TestCase $this->assertEquals($result->description, $data['description']); $this->assertEquals($result->amount, 50); } + /** * @covers FireflyIII\Repositories\Journal\JournalRepository::update * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.php index 855ec366d5..8810a6dfe4 100644 --- a/tests/repositories/TagRepositoryTest.php +++ b/tests/repositories/TagRepositoryTest.php @@ -380,7 +380,7 @@ class TagRepositoryTest extends TestCase */ public function testUpdate() { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); + $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $data = [