diff --git a/app/Handlers/Events/UpdatedJournalEventHandler.php b/app/Handlers/Events/UpdatedJournalEventHandler.php index 20e446ea5e..a99a078374 100644 --- a/app/Handlers/Events/UpdatedJournalEventHandler.php +++ b/app/Handlers/Events/UpdatedJournalEventHandler.php @@ -51,6 +51,7 @@ class UpdatedJournalEventHandler /** * This method will check all the rules when a journal is updated. + * TODO move to factory. * * @param UpdatedTransactionJournal $updatedJournalEvent * @@ -81,6 +82,7 @@ class UpdatedJournalEventHandler /** * This method calls a special bill scanner that will check if the updated journal is part of a bill. + * TODO move to factory. * * @param UpdatedTransactionJournal $updatedJournalEvent * diff --git a/app/Helpers/Chart/MetaPieChart.php b/app/Helpers/Chart/MetaPieChart.php index 91e28f0ee0..931b996360 100644 --- a/app/Helpers/Chart/MetaPieChart.php +++ b/app/Helpers/Chart/MetaPieChart.php @@ -276,11 +276,13 @@ class MetaPieChart implements MetaPieChartInterface $collector->setBudgets($this->budgets); $collector->setCategories($this->categories); + // @codeCoverageIgnoreStart if ($this->tags->count() > 0) { $collector->setTags($this->tags); $collector->withCategoryInformation(); $collector->withBudgetInformation(); } + // @codeCoverageIgnoreEnd return $collector->getJournals(); } @@ -297,7 +299,7 @@ class MetaPieChart implements MetaPieChartInterface { if (0 === count($fields) && $this->tags->count() > 0) { // do a special group on tags: - return $this->groupByTag($set); + return $this->groupByTag($set); // @codeCoverageIgnore } $grouped = []; @@ -341,6 +343,8 @@ class MetaPieChart implements MetaPieChartInterface } /** + * @codeCoverageIgnore + * * @param Collection $set * * @return array diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 57a57ae19d..98f3c8f978 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -297,7 +297,7 @@ class AccountController extends Controller $end = app('navigation')->endOfPeriod($start, $range); } if ($end < $start) { - throw new FireflyException('End is after start!'); + throw new FireflyException('End is after start!'); // @codeCoverageIgnore } $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); @@ -417,7 +417,7 @@ class AccountController extends Controller $start = $this->repository->oldestJournalDate($account); $end = $date ?? new Carbon; if ($end < $start) { - list($start, $end) = [$end, $start]; + list($start, $end) = [$end, $start]; // @codeCoverageIgnore } // properties for cache diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index f098c9c820..24210ebf34 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -328,28 +328,4 @@ class BillController extends Controller return redirect($this->getPreviousUri('bills.edit.uri')); } - - /** - * Returns the latest date in the set, or start when set is empty. - * - * @param Collection $dates - * @param Carbon $default - * - * @return Carbon - */ - private function lastPaidDate(Collection $dates, Carbon $default): Carbon - { - if (0 === $dates->count()) { - return $default; // @codeCoverageIgnore - } - $latest = $dates->first(); - /** @var Carbon $date */ - foreach ($dates as $date) { - if ($date->gte($latest)) { - $latest = $date; - } - } - - return $latest; - } } diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index b96bef9e43..baf19747d6 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -316,7 +316,7 @@ class AccountController extends Controller $step = '1D'; $months = $start->diffInMonths($end); if ($months > 3) { - $step = '1W'; + $step = '1W'; // @codeCoverageIgnore } if ($months > 24) { $step = '1M'; // @codeCoverageIgnore @@ -340,9 +340,10 @@ class AccountController extends Controller $current->addDay(); } break; + // @codeCoverageIgnoreStart case '1W': - case '1M': // @codeCoverageIgnore - case '1Y': // @codeCoverageIgnore + case '1M': + case '1Y': while ($end >= $current) { $balance = floatval(app('steam')->balance($account, $current)); $label = app('navigation')->periodShow($current, $step); @@ -350,6 +351,7 @@ class AccountController extends Controller $current = app('navigation')->addPeriod($current, $step, 1); } break; + // @codeCoverageIgnoreEnd } $data = $this->generator->singleSet($account->name, $chartData); $cache->store($data); diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index b263917b08..b82633bef4 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -95,7 +95,7 @@ class SplitController extends Controller public function edit(Request $request, TransactionJournal $journal) { if ($this->isOpeningBalance($journal)) { - return $this->redirectToAccount($journal); + return $this->redirectToAccount($journal); // @codeCoverageIgnore } $uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size'))); @@ -140,7 +140,7 @@ class SplitController extends Controller public function update(SplitJournalFormRequest $request, TransactionJournal $journal) { if ($this->isOpeningBalance($journal)) { - return $this->redirectToAccount($journal); + return $this->redirectToAccount($journal); // @codeCoverageIgnore } $data = $request->getAll(); $journal = $this->repository->update($journal, $data); diff --git a/tests/Api/V1/Controllers/UserControllerTest.php b/tests/Api/V1/Controllers/UserControllerTest.php index 1c73ec0582..88d3beed2a 100644 --- a/tests/Api/V1/Controllers/UserControllerTest.php +++ b/tests/Api/V1/Controllers/UserControllerTest.php @@ -103,7 +103,7 @@ class UserControllerTest extends TestCase $response = $this->get('/api/v1/users'); $response->assertStatus(200); $response->assertJson(['data' => [],]); - $response->assertJson(['meta' => ['pagination' => ['total' => 10, 'count' => 10, 'per_page' => 50, 'current_page' => 1, 'total_pages' => 1]],]); + $response->assertJson(['meta' => ['pagination' => ['total' => 10, 'count' => 10, 'current_page' => 1, 'total_pages' => 1]],]); $response->assertJson( ['links' => ['self' => true, 'first' => true, 'last' => true,],] ); diff --git a/tests/Feature/Controllers/Account/ReconcileControllerTest.php b/tests/Feature/Controllers/Account/ReconcileControllerTest.php index 27dd4d6eca..4c183134b4 100644 --- a/tests/Feature/Controllers/Account/ReconcileControllerTest.php +++ b/tests/Feature/Controllers/Account/ReconcileControllerTest.php @@ -91,9 +91,10 @@ class ReconcileControllerTest extends TestCase */ public function testOverview() { + $transactions = $this->user()->transactions()->inRandomOrder()->take(3)->get(); $repository = $this->mock(JournalRepositoryInterface::class); $repository->shouldReceive('first')->andReturn(new TransactionJournal); - $repository->shouldReceive('getTransactionsById')->andReturn(new Collection())->twice(); + $repository->shouldReceive('getTransactionsById')->andReturn($transactions)->twice(); $parameters = [ 'startBalance' => '0', diff --git a/tests/Feature/Controllers/AccountControllerTest.php b/tests/Feature/Controllers/AccountControllerTest.php index ba83d35bb3..7ea250cfea 100644 --- a/tests/Feature/Controllers/AccountControllerTest.php +++ b/tests/Feature/Controllers/AccountControllerTest.php @@ -214,6 +214,23 @@ class AccountControllerTest extends TestCase $response->assertSee('