mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage.
This commit is contained in:
@@ -46,11 +46,13 @@ class BudgetList implements BinderInterface
|
||||
//Log::debug(sprintf('Now in BudgetList::routeBinder("%s")', $value));
|
||||
if (auth()->check()) {
|
||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||
//Log::debug('List is now', $list);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (0 === count($list)) {
|
||||
Log::warning('Budget list count is zero, return 404.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
/** @var Collection $collection */
|
||||
$collection = auth()->user()->budgets()
|
||||
|
@@ -44,8 +44,14 @@ class ImportProvider implements BinderInterface
|
||||
{
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
// get and filter all import routines:
|
||||
|
||||
if (!auth()->check()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var array $config */
|
||||
$providerNames = array_keys(config('import.enabled'));
|
||||
$providers = [];
|
||||
@@ -55,13 +61,20 @@ class ImportProvider implements BinderInterface
|
||||
// only consider enabled providers
|
||||
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
|
||||
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName));
|
||||
$allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName));
|
||||
if (false === $enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
|
||||
continue; // @codeCoverageIgnore
|
||||
if (false === $allowedForUser && !$isDemoUser) {
|
||||
continue;
|
||||
}
|
||||
if (false === $allowedForDemo && $isDemoUser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$providers[$providerName] = [
|
||||
'has_prereq' => (bool)config('import.has_prereq.' . $providerName),
|
||||
|
@@ -46,17 +46,20 @@ class TagList implements BinderInterface
|
||||
if (auth()->check()) {
|
||||
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
||||
Log::debug('List of tags is', $list);
|
||||
// @codeCoverageIgnoreStart
|
||||
if (0 === count($list)) {
|
||||
Log::error('Tag list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
$allTags = $repository->get();
|
||||
|
||||
$collection = $allTags->filter(
|
||||
function (Tag $tag) use ($list) {
|
||||
static function (Tag $tag) use ($list) {
|
||||
if (in_array(strtolower($tag->tag), $list, true)) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionGroup.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Routing\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class TransactionGroup.
|
||||
*/
|
||||
class TransactionGroup implements BinderInterface
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return TransactionGroup
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): TransactionGroup
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$group = auth()->user()->transactionGroups()
|
||||
->find($value);
|
||||
if (null !== $group) {
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* UnfinishedJournal.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Routing\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class Date.
|
||||
*/
|
||||
class UnfinishedJournal implements BinderInterface
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return TransactionJournal
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): TransactionJournal
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$journal = auth()->user()->transactionJournals()->where('transaction_journals.id', $value)
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->where('completed', 0)
|
||||
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
|
||||
if (null !== $journal) {
|
||||
return $journal;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user