mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-15 17:24:11 +00:00
Applied latest styleci changes
This commit is contained in:
parent
747f81d5d8
commit
f3c147d33b
4 changed files with 17 additions and 17 deletions
app
tests
|
@ -6,7 +6,6 @@ use Whoops\Handler\Handler;
|
||||||
|
|
||||||
class WhoopsBookStackPrettyHandler extends Handler
|
class WhoopsBookStackPrettyHandler extends Handler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null A handler may return nothing, or a Handler::HANDLE_* constant
|
* @return int|null A handler may return nothing, or a Handler::HANDLE_* constant
|
||||||
*/
|
*/
|
||||||
|
@ -15,16 +14,17 @@ class WhoopsBookStackPrettyHandler extends Handler
|
||||||
$exception = $this->getException();
|
$exception = $this->getException();
|
||||||
|
|
||||||
echo view('errors.debug', [
|
echo view('errors.debug', [
|
||||||
'error' => $exception->getMessage(),
|
'error' => $exception->getMessage(),
|
||||||
'errorClass' => get_class($exception),
|
'errorClass' => get_class($exception),
|
||||||
'trace' => $exception->getTraceAsString(),
|
'trace' => $exception->getTraceAsString(),
|
||||||
'environment' => $this->getEnvironment(),
|
'environment' => $this->getEnvironment(),
|
||||||
])->render();
|
])->render();
|
||||||
|
|
||||||
return Handler::QUIT;
|
return Handler::QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function safeReturn(callable $callback, $default = null) {
|
protected function safeReturn(callable $callback, $default = null)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
return $callback();
|
return $callback();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -35,14 +35,15 @@ class WhoopsBookStackPrettyHandler extends Handler
|
||||||
protected function getEnvironment(): array
|
protected function getEnvironment(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'PHP Version' => phpversion(),
|
'PHP Version' => phpversion(),
|
||||||
'BookStack Version' => $this->safeReturn(function() {
|
'BookStack Version' => $this->safeReturn(function () {
|
||||||
$versionFile = base_path('version');
|
$versionFile = base_path('version');
|
||||||
|
|
||||||
return trim(file_get_contents($versionFile));
|
return trim(file_get_contents($versionFile));
|
||||||
}, 'unknown'),
|
}, 'unknown'),
|
||||||
'Theme Configured' => $this->safeReturn(function() {
|
'Theme Configured' => $this->safeReturn(function () {
|
||||||
return config('view.theme');
|
return config('view.theme');
|
||||||
}) ?? 'None',
|
}) ?? 'None',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(HandlerInterface::class, function($app) {
|
$this->app->bind(HandlerInterface::class, function ($app) {
|
||||||
return $app->make(WhoopsBookStackPrettyHandler::class);
|
return $app->make(WhoopsBookStackPrettyHandler::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ class MfaConfigurationTest extends TestCase
|
||||||
|
|
||||||
$resp = $this->get('/mfa/totp/generate');
|
$resp = $this->get('/mfa/totp/generate');
|
||||||
$resp->assertSeeText('Mobile App Setup');
|
$resp->assertSeeText('Mobile App Setup');
|
||||||
$resp->assertDontSee("otpauth://totp/BookStack:guest%40example.com");
|
$resp->assertDontSee('otpauth://totp/BookStack:guest%40example.com');
|
||||||
$resp->assertSee("otpauth://totp/BookStack:admin%40admin.com");
|
$resp->assertSee('otpauth://totp/BookStack:admin%40admin.com');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,12 @@ class DebugViewTest extends TestCase
|
||||||
$resp->assertSeeText('An unknown error occurred');
|
$resp->assertSeeText('An unknown error occurred');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getDebugViewForException(\Exception $exception): TestResponse
|
protected function getDebugViewForException(\Exception $exception): TestResponse
|
||||||
{
|
{
|
||||||
// Fake an error via social auth service used on login page
|
// Fake an error via social auth service used on login page
|
||||||
$mockService = $this->mock(SocialAuthService::class);
|
$mockService = $this->mock(SocialAuthService::class);
|
||||||
$mockService->shouldReceive('getActiveDrivers')->andThrow($exception);
|
$mockService->shouldReceive('getActiveDrivers')->andThrow($exception);
|
||||||
|
|
||||||
return $this->get('/login');
|
return $this->get('/login');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue