Path: blob/1.0-develop/tests/Integration/TestResponse.php
7458 views
<?php12namespace Pterodactyl\Tests\Integration;34use Illuminate\Http\Response;5use Illuminate\Testing\Assert as PHPUnit;6use Pterodactyl\Exceptions\DisplayException;7use Illuminate\Validation\ValidationException;8use Illuminate\Testing\TestResponse as IlluminateTestResponse;910class TestResponse extends IlluminateTestResponse11{12/**13* Overrides the default assert status logic to dump out the error to the14* test output if it is caused by a 500 level error, and we were not specifically15* look for that status response.16*/17public function assertStatus($status): TestResponse18{19$actual = $this->getStatusCode();2021// Dump the response to the screen before making the assertion which is going22// to fail so that debugging isn't such a nightmare.23if ($actual !== $status && $status !== 500) {24$this->dump();25if (!is_null($this->exception) && !$this->exception instanceof DisplayException && !$this->exception instanceof ValidationException) {26dump([27'exception_class' => get_class($this->exception),28'message' => $this->exception->getMessage(),29'trace' => $this->exception->getTrace(),30]);31}32}3334PHPUnit::assertSame($actual, $status, "Expected status code {$status} but received {$actual}.");3536return $this;37}3839public function assertForbidden(): self40{41return self::assertStatus(Response::HTTP_FORBIDDEN);42}43}444546