diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index b77959058..dc12a341b 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -15,6 +15,7 @@ use Pterodactyl\Models\Location; use Pterodactyl\Models\Schedule; use Illuminate\Support\Collection; use Pterodactyl\Models\Allocation; +use Pterodactyl\Tests\Integration\TestResponse; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Transformers\Api\Client\BaseClientTransformer; @@ -44,6 +45,19 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase CarbonImmutable::setTestNow(Carbon::now()); } + /** + * Override the default createTestResponse from Illuminate so that we can + * just dump 500-level errors to the screen in the tests without having + * to keep re-assigning variables. + * + * @param \Illuminate\Http\Response $response + * @return \Illuminate\Testing\TestResponse + */ + protected function createTestResponse($response) + { + return TestResponse::fromBaseResponse($response); + } + /** * Returns a link to the specific resource using the client API. * diff --git a/tests/Integration/TestResponse.php b/tests/Integration/TestResponse.php new file mode 100644 index 000000000..9a4c6491b --- /dev/null +++ b/tests/Integration/TestResponse.php @@ -0,0 +1,35 @@ +getStatusCode(); + + // Dump the response to the screen before making the assertion which is going + // to fail so that debugging isn't such a nightmare. + if ($actual !== $status && $status !== 500) { + $this->dump(); + if (! is_null($this->exception)) { + dump($this->exception); + } + } + + PHPUnit::assertSame($actual, $status, "Expected status code {$status} but received {$actual}."); + + return $this; + } +}