From 226e2f718580213e7c30330f2cc460c830ca8392 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 23 Jul 2019 17:33:23 +0200 Subject: [PATCH] Improve test coverage. --- .../Controllers/Chart/CategoryController.php | 4 +- .../Controllers/TransactionController.php | 97 --------- phpunit.coverage.specific.xml | 15 +- phpunit.coverage.xml | 15 +- phpunit.xml | 17 +- .../Account/CreateControllerTest.php | 18 +- .../Account/DeleteControllerTest.php | 15 +- .../Account/IndexControllerTest.php | 10 +- .../Account/ReconcileControllerTest.php | 3 + .../Account/ShowControllerTest.php | 29 +-- .../Admin/ConfigurationControllerTest.php | 21 +- .../Controllers/Admin/HomeControllerTest.php | 14 +- .../Controllers/Admin/LinkControllerTest.php | 16 +- .../Controllers/AttachmentControllerTest.php | 3 +- .../Auth/TwoFactorControllerTest.php | 3 + .../Controllers/BillControllerTest.php | 6 +- .../Budget/IndexControllerTest.php | 6 + .../Category/IndexControllerTest.php | 2 +- .../Category/NoCategoryControllerTest.php | 1 - .../Chart/TagReportControllerTest.php | 4 +- .../Controllers/CurrencyControllerTest.php | 24 +-- .../Import/PrerequisitesControllerTest.php | 7 + .../Controllers/Json/BoxControllerTest.php | 5 + .../Json/ExchangeControllerTest.php | 10 +- .../Controllers/Json/RuleControllerTest.php | 6 +- .../Controllers/PreferencesControllerTest.php | 6 +- .../Controllers/ProfileControllerTest.php | 2 - .../Report/AccountControllerTest.php | 1 + .../Report/BalanceControllerTest.php | 1 + .../Report/BudgetControllerTest.php | 2 + .../Report/CategoryControllerTest.php | 5 +- .../Report/ExpenseControllerTest.php | 1 + .../Report/OperationsControllerTest.php | 3 + .../Controllers/Rule/SelectControllerTest.php | 6 +- .../Transaction/ConvertControllerTest.php | 6 - .../Transaction/LinkControllerTest.php | 2 +- .../Controllers/TransactionControllerTest.php | 188 ------------------ tests/TestCase.php | 9 + 38 files changed, 132 insertions(+), 451 deletions(-) delete mode 100644 app/Http/Controllers/TransactionController.php delete mode 100644 tests/Feature/Controllers/TransactionControllerTest.php diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index ef557369c2..50c6694dbd 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -115,7 +115,7 @@ class CategoryController extends Controller switch ($step) { case '1D': while ($current <= $end) { - Log::debug(sprintf('Current day is %s', $current->format('Y-m-d'))); + //Log::debug(sprintf('Current day is %s', $current->format('Y-m-d'))); $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $current); $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $current); $sum = bcadd($spent, $earned); @@ -134,7 +134,7 @@ class CategoryController extends Controller // @codeCoverageIgnoreEnd while ($current <= $end) { $currentEnd = app('navigation')->endOfPeriod($current, $step); - Log::debug(sprintf('abc Range is %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d'))); + //Log::debug(sprintf('abc Range is %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d'))); $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $currentEnd); $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $currentEnd); diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php deleted file mode 100644 index b3eb297850..0000000000 --- a/app/Http/Controllers/TransactionController.php +++ /dev/null @@ -1,97 +0,0 @@ -. - */ -/** @noinspection CallableParameterUseCaseInTypeContextInspection */ -/** @noinspection MoreThanThreeArgumentsInspection */ -declare(strict_types=1); - -namespace FireflyIII\Http\Controllers; - -use Carbon\Carbon; -use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface; -use FireflyIII\Repositories\Journal\JournalRepositoryInterface; -use FireflyIII\Support\Http\Controllers\ModelInformation; -use FireflyIII\Support\Http\Controllers\PeriodOverview; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; -use Log; - -/** - * Class TransactionController. - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class TransactionController extends Controller -{ - use ModelInformation, PeriodOverview; - /** @var AttachmentRepositoryInterface */ - private $attachmentRepository; - /** @var JournalRepositoryInterface Journals and transactions overview */ - private $repository; - - /** - * TransactionController constructor. - */ - public function __construct() - { - parent::__construct(); - - $this->middleware( - function ($request, $next) { - app('view')->share('title', (string)trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); - $this->repository = app(JournalRepositoryInterface::class); - $this->attachmentRepository = app(AttachmentRepositoryInterface::class); - - return $next($request); - } - ); - } - - /** - * Reorder transactions. - * - * @param Request $request - * - * @return \Illuminate\Http\JsonResponse - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function reorder(Request $request): JsonResponse - { - $ids = $request->get('items'); - $date = new Carbon($request->get('date')); - if (count($ids) > 0) { - $order = 0; - $ids = array_unique($ids); - foreach ($ids as $id) { - $journal = $this->repository->findNull((int)$id); - if (null !== $journal && $journal->date->isSameDay($date)) { - $this->repository->setOrder($journal, $order); - ++$order; - } - } - } - app('preferences')->mark(); - - return response()->json([true]); - } - - -} diff --git a/phpunit.coverage.specific.xml b/phpunit.coverage.specific.xml index 87cb0e2e09..6bda37786d 100644 --- a/phpunit.coverage.specific.xml +++ b/phpunit.coverage.specific.xml @@ -45,20 +45,7 @@ ./tests/Unit/Helpers - ./tests/Feature/Controllers/Account - ./tests/Feature/Controllers/Admin - ./tests/Feature/Controllers/Budget - ./tests/Feature/Controllers/Category - ./tests/Feature/Controllers/Chart - ./tests/Feature/Controllers/Import - ./tests/Feature/Controllers/Json - ./tests/Feature/Controllers/Popup - ./tests/Feature/Controllers/Recurring - ./tests/Feature/Controllers/Report - ./tests/Feature/Controllers/Rule - ./tests/Feature/Controllers/RuleGroup - ./tests/Feature/Controllers/System - ./tests/Feature/Controllers/Transaction + ./tests/Feature diff --git a/phpunit.coverage.xml b/phpunit.coverage.xml index 5554db36f8..333c94a1d0 100644 --- a/phpunit.coverage.xml +++ b/phpunit.coverage.xml @@ -45,20 +45,7 @@ ./tests/Unit/Helpers - ./tests/Feature/Controllers/Account - ./tests/Feature/Controllers/Admin - ./tests/Feature/Controllers/Budget - ./tests/Feature/Controllers/Category - ./tests/Feature/Controllers/Chart - ./tests/Feature/Controllers/Import - ./tests/Feature/Controllers/Json - ./tests/Feature/Controllers/Popup - ./tests/Feature/Controllers/Recurring - ./tests/Feature/Controllers/Report - ./tests/Feature/Controllers/Rule - ./tests/Feature/Controllers/RuleGroup - ./tests/Feature/Controllers/System - ./tests/Feature/Controllers/Transaction + ./tests/Feature diff --git a/phpunit.xml b/phpunit.xml index d9961c48a3..8eca141481 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -45,22 +45,7 @@ ./tests/Unit/Helpers - ./tests/Feature/Controllers/Account - ./tests/Feature/Controllers/Admin - ./tests/Feature/Controllers/Budget - ./tests/Feature/Controllers/Category - ./tests/Feature/Controllers/Chart - ./tests/Feature/Controllers/Import - ./tests/Feature/Controllers/Json - ./tests/Feature/Controllers/Popup - ./tests/Feature/Controllers/Recurring - ./tests/Feature/Controllers/Report - ./tests/Feature/Controllers/Rule - ./tests/Feature/Controllers/RuleGroup - ./tests/Feature/Controllers/System - ./tests/Feature/Controllers/Transaction - ./tests/Feature/Controllers/AttachmentControllerTest.php - + ./tests/Feature