File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1515use Pterodactyl \Models \Schedule ;
1616use Illuminate \Support \Collection ;
1717use Pterodactyl \Models \Allocation ;
18+ use Pterodactyl \Tests \Integration \TestResponse ;
1819use Pterodactyl \Tests \Integration \IntegrationTestCase ;
1920use Pterodactyl \Transformers \Api \Client \BaseClientTransformer ;
2021
@@ -44,6 +45,19 @@ public function setUp(): void
4445 CarbonImmutable::setTestNow (Carbon::now ());
4546 }
4647
48+ /**
49+ * Override the default createTestResponse from Illuminate so that we can
50+ * just dump 500-level errors to the screen in the tests without having
51+ * to keep re-assigning variables.
52+ *
53+ * @param \Illuminate\Http\Response $response
54+ * @return \Illuminate\Testing\TestResponse
55+ */
56+ protected function createTestResponse ($ response )
57+ {
58+ return TestResponse::fromBaseResponse ($ response );
59+ }
60+
4761 /**
4862 * Returns a link to the specific resource using the client API.
4963 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Pterodactyl \Tests \Integration ;
4+
5+ use Illuminate \Testing \Assert as PHPUnit ;
6+ use Illuminate \Testing \TestResponse as IlluminateTestResponse ;
7+
8+ class TestResponse extends IlluminateTestResponse
9+ {
10+ /**
11+ * Overrides the default assert status logic to dump out the error to the
12+ * test output if it is caused by a 500 level error and we were not specifically
13+ * look for that status response.
14+ *
15+ * @param int $status
16+ * @return \Pterodactyl\Tests\Integration\TestResponse
17+ */
18+ public function assertStatus ($ status )
19+ {
20+ $ actual = $ this ->getStatusCode ();
21+
22+ // Dump the response to the screen before making the assertion which is going
23+ // to fail so that debugging isn't such a nightmare.
24+ if ($ actual !== $ status && $ status !== 500 ) {
25+ $ this ->dump ();
26+ if (! is_null ($ this ->exception )) {
27+ dump ($ this ->exception );
28+ }
29+ }
30+
31+ PHPUnit::assertSame ($ actual , $ status , "Expected status code {$ status } but received {$ actual }. " );
32+
33+ return $ this ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments