From f3c147d33bc3457350e7e971a3bfd074493ee36d Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Fri, 15 Oct 2021 14:16:45 +0100 Subject: [PATCH] Applied latest styleci changes --- .../WhoopsBookStackPrettyHandler.php | 23 ++++++++++--------- app/Providers/AppServiceProvider.php | 2 +- tests/Auth/MfaConfigurationTest.php | 4 ++-- tests/DebugViewTest.php | 5 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Exceptions/WhoopsBookStackPrettyHandler.php b/app/Exceptions/WhoopsBookStackPrettyHandler.php index 22a49e04a..dcf50fa8e 100644 --- a/app/Exceptions/WhoopsBookStackPrettyHandler.php +++ b/app/Exceptions/WhoopsBookStackPrettyHandler.php @@ -6,7 +6,6 @@ use Whoops\Handler\Handler; class WhoopsBookStackPrettyHandler extends Handler { - /** * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant */ @@ -15,16 +14,17 @@ class WhoopsBookStackPrettyHandler extends Handler $exception = $this->getException(); echo view('errors.debug', [ - 'error' => $exception->getMessage(), - 'errorClass' => get_class($exception), - 'trace' => $exception->getTraceAsString(), + 'error' => $exception->getMessage(), + 'errorClass' => get_class($exception), + 'trace' => $exception->getTraceAsString(), 'environment' => $this->getEnvironment(), ])->render(); return Handler::QUIT; } - protected function safeReturn(callable $callback, $default = null) { + protected function safeReturn(callable $callback, $default = null) + { try { return $callback(); } catch (\Exception $e) { @@ -35,14 +35,15 @@ class WhoopsBookStackPrettyHandler extends Handler protected function getEnvironment(): array { return [ - 'PHP Version' => phpversion(), - 'BookStack Version' => $this->safeReturn(function() { + 'PHP Version' => phpversion(), + 'BookStack Version' => $this->safeReturn(function () { $versionFile = base_path('version'); + return trim(file_get_contents($versionFile)); }, 'unknown'), - 'Theme Configured' => $this->safeReturn(function() { - return config('view.theme'); - }) ?? 'None', + 'Theme Configured' => $this->safeReturn(function () { + return config('view.theme'); + }) ?? 'None', ]; } -} \ No newline at end of file +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 0316b02aa..4446c2a0a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -67,7 +67,7 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - $this->app->bind(HandlerInterface::class, function($app) { + $this->app->bind(HandlerInterface::class, function ($app) { return $app->make(WhoopsBookStackPrettyHandler::class); }); diff --git a/tests/Auth/MfaConfigurationTest.php b/tests/Auth/MfaConfigurationTest.php index 4223d052d..59a2a41b5 100644 --- a/tests/Auth/MfaConfigurationTest.php +++ b/tests/Auth/MfaConfigurationTest.php @@ -180,7 +180,7 @@ class MfaConfigurationTest extends TestCase $resp = $this->get('/mfa/totp/generate'); $resp->assertSeeText('Mobile App Setup'); - $resp->assertDontSee("otpauth://totp/BookStack:guest%40example.com"); - $resp->assertSee("otpauth://totp/BookStack:admin%40admin.com"); + $resp->assertDontSee('otpauth://totp/BookStack:guest%40example.com'); + $resp->assertSee('otpauth://totp/BookStack:admin%40admin.com'); } } diff --git a/tests/DebugViewTest.php b/tests/DebugViewTest.php index 3485b4598..63d6472b9 100644 --- a/tests/DebugViewTest.php +++ b/tests/DebugViewTest.php @@ -42,13 +42,12 @@ class DebugViewTest extends TestCase $resp->assertSeeText('An unknown error occurred'); } - protected function getDebugViewForException(\Exception $exception): TestResponse { // Fake an error via social auth service used on login page $mockService = $this->mock(SocialAuthService::class); $mockService->shouldReceive('getActiveDrivers')->andThrow($exception); + return $this->get('/login'); } - -} \ No newline at end of file +}