mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-10-13 17:02:06 -05:00
Improve test coverage.
This commit is contained in:
28 files changed
+414
-98
No files matched your search
@@ -98,6 +98,7 @@ class Authenticate
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
return $this->auth->shouldUse($guard);
|
||||
@@ -105,5 +106,6 @@ class Authenticate
|
||||
}
|
||||
|
||||
throw new AuthenticationException('Unauthenticated.', $guards);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
@@ -34,26 +34,28 @@ use Session;
|
||||
class IsDemoUser
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user).
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string[] ...$guards
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
// don't care when not logged in, usual stuff applies:
|
||||
/** @var User $user */
|
||||
$user = $request->user();
|
||||
if (is_null($user)) {
|
||||
return $next($request);
|
||||
}
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->hasRole('demo')) {
|
||||
Session::flash('info', strval(trans('firefly.not_available_demo_user')));
|
||||
|
||||
return redirect($request->session()->previousUrl());
|
||||
redirect($request->session()->previousUrl());
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -38,35 +38,17 @@ use View;
|
||||
*/
|
||||
class Range
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null $guard
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (!Auth::guard($guard)->guest()) {
|
||||
if ($request->user()) {
|
||||
// set start, end and finish:
|
||||
$this->setRange();
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class JournalFormRequest extends Request
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new FireflyException('Cannot handle transaction type of type ' . e($what) . ' . ');
|
||||
throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $what)); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
||||
@@ -47,7 +47,7 @@ class ReconciliationStoreRequest extends Request
|
||||
{
|
||||
$transactions = $this->get('transactions');
|
||||
if (!is_array($transactions)) {
|
||||
$transactions = [];
|
||||
$transactions = []; // @codeCoverageIgnore
|
||||
}
|
||||
$data = [
|
||||
'start' => $this->date('start'),
|
||||
|
||||
@@ -122,9 +122,12 @@ class ReportFormRequest extends Request
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[1]);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Exception $e) {
|
||||
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $date;
|
||||
@@ -165,8 +168,10 @@ class ReportFormRequest extends Request
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[0]);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Exception $e) {
|
||||
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,15 +120,4 @@ class Request extends FormRequest
|
||||
{
|
||||
return $this->get($field) ? new Carbon($this->get($field)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function float(string $field): float
|
||||
{
|
||||
return round($this->input($field), 12);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user