mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-26 02:03:45 +02:00
Make debugging test failures easier
This commit is contained in:
35
tests/Integration/TestResponse.php
Normal file
35
tests/Integration/TestResponse.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Tests\Integration;
|
||||
|
||||
use Illuminate\Testing\Assert as PHPUnit;
|
||||
use Illuminate\Testing\TestResponse as IlluminateTestResponse;
|
||||
|
||||
class TestResponse extends IlluminateTestResponse
|
||||
{
|
||||
/**
|
||||
* Overrides the default assert status logic to dump out the error to the
|
||||
* test output if it is caused by a 500 level error and we were not specifically
|
||||
* look for that status response.
|
||||
*
|
||||
* @param int $status
|
||||
* @return \Pterodactyl\Tests\Integration\TestResponse
|
||||
*/
|
||||
public function assertStatus($status)
|
||||
{
|
||||
$actual = $this->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user