REDROOM
PHP 8.3.31
Path:
Logout
Edit File
Size: 6.65 KB
Close
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php
Text
Base64
<?php namespace Illuminate\Foundation\Testing\Concerns; use Closure; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Support\Testing\Fakes\ExceptionHandlerFake; use Illuminate\Support\Traits\ReflectsClosures; use Illuminate\Testing\Assert; use Illuminate\Validation\ValidationException; use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Throwable; trait InteractsWithExceptionHandling { use ReflectsClosures; /** * The original exception handler. * * @var \Illuminate\Contracts\Debug\ExceptionHandler|null */ protected $originalExceptionHandler; /** * Restore exception handling. * * @return $this */ protected function withExceptionHandling() { if ($this->originalExceptionHandler) { $currentExceptionHandler = app(ExceptionHandler::class); $currentExceptionHandler instanceof ExceptionHandlerFake ? $currentExceptionHandler->setHandler($this->originalExceptionHandler) : $this->app->instance(ExceptionHandler::class, $this->originalExceptionHandler); } return $this; } /** * Only handle the given exceptions via the exception handler. * * @param array $exceptions * @return $this */ protected function handleExceptions(array $exceptions) { return $this->withoutExceptionHandling($exceptions); } /** * Only handle validation exceptions via the exception handler. * * @return $this */ protected function handleValidationExceptions() { return $this->handleExceptions([ValidationException::class]); } /** * Disable exception handling for the test. * * @param array $except * @return $this */ protected function withoutExceptionHandling(array $except = []) { if ($this->originalExceptionHandler == null) { $currentExceptionHandler = app(ExceptionHandler::class); $this->originalExceptionHandler = $currentExceptionHandler instanceof ExceptionHandlerFake ? $currentExceptionHandler->handler() : $currentExceptionHandler; } $exceptionHandler = new class($this->originalExceptionHandler, $except) implements ExceptionHandler, WithoutExceptionHandlingHandler { protected $except; protected $originalHandler; /** * Create a new class instance. * * @param \Illuminate\Contracts\Debug\ExceptionHandler $originalHandler * @param array $except * @return void */ public function __construct($originalHandler, $except = []) { $this->except = $except; $this->originalHandler = $originalHandler; } /** * Report or log an exception. * * @param \Throwable $e * @return void * * @throws \Exception */ public function report(Throwable $e) { // } /** * Determine if the exception should be reported. * * @param \Throwable $e * @return bool */ public function shouldReport(Throwable $e) { return false; } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Throwable $e * @return \Symfony\Component\HttpFoundation\Response * * @throws \Throwable */ public function render($request, Throwable $e) { foreach ($this->except as $class) { if ($e instanceof $class) { return $this->originalHandler->render($request, $e); } } if ($e instanceof NotFoundHttpException) { throw new NotFoundHttpException( "{$request->method()} {$request->url()}", $e, is_int($e->getCode()) ? $e->getCode() : 0 ); } throw $e; } /** * Render an exception to the console. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Throwable $e * @return void */ public function renderForConsole($output, Throwable $e) { (new ConsoleApplication)->renderThrowable($e, $output); } }; $currentExceptionHandler = app(ExceptionHandler::class); $currentExceptionHandler instanceof ExceptionHandlerFake ? $currentExceptionHandler->setHandler($exceptionHandler) : $this->app->instance(ExceptionHandler::class, $exceptionHandler); return $this; } /** * Assert that the given callback throws an exception with the given message when invoked. * * @param \Closure $test * @param \Closure|class-string<\Throwable> $expectedClass * @param string|null $expectedMessage * @return $this */ protected function assertThrows(Closure $test, string|Closure $expectedClass = Throwable::class, ?string $expectedMessage = null) { [$expectedClass, $expectedClassCallback] = $expectedClass instanceof Closure ? [$this->firstClosureParameterType($expectedClass), $expectedClass] : [$expectedClass, null]; try { $test(); $thrown = false; } catch (Throwable $exception) { $thrown = $exception instanceof $expectedClass && ($expectedClassCallback === null || $expectedClassCallback($exception)); $actualMessage = $exception->getMessage(); } Assert::assertTrue( $thrown, sprintf('Failed asserting that exception of type "%s" was thrown.', $expectedClass) ); if (isset($expectedMessage)) { if (! isset($actualMessage)) { Assert::fail( sprintf( 'Failed asserting that exception of type "%s" with message "%s" was thrown.', $expectedClass, $expectedMessage ) ); } else { Assert::assertStringContainsString($expectedMessage, $actualMessage); } } return $this; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 13
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
InteractsWithAuthentication.php
3.92 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithConsole.php
2.08 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithContainer.php
6.48 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithDatabase.php
9.82 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithDeprecationHandling.php
1.16 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithExceptionHandling.php
6.65 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithRedis.php
3.01 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithSession.php
1.12 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithTestCaseLifecycle.php
7.94 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithTime.php
1.49 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InteractsWithViews.php
2.34 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MakesHttpRequests.php
20.02 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
WithoutExceptionHandlingHandler.php
111 B
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).