Skip to content

Commit

Permalink
[11.x] Restore exceptions/errors to test assertion failure messages (#…
Browse files Browse the repository at this point in the history
…51725)

* Restore exceptions/errors to test assertion failure messages

* Update Testbench

* Fix tests on Windows

* Update composer.json

---------

Co-authored-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
jessarcher and crynobone authored Jun 6, 2024
1 parent 454e9dc commit 8ce249a
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 338 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"league/flysystem-sftp-v3": "^3.0",
"mockery/mockery": "^1.6",
"nyholm/psr7": "^1.2",
"orchestra/testbench-core": "^9.0.15",
"orchestra/testbench-core": "^9.1.4",
"pda/pheanstalk": "^5.0",
"phpstan/phpstan": "^1.4.7",
"phpunit/phpunit": "^10.5|^11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ trait MakesHttpRequests
*/
protected $withCredentials = false;

/**
* The latest test response (if any).
*
* @var \Illuminate\Testing\TestResponse|null
*/
public static $latestResponse;

/**
* Define additional headers to be sent with the request.
*
Expand Down Expand Up @@ -592,7 +585,7 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = []
$response = $this->followRedirects($response);
}

return static::$latestResponse = $this->createTestResponse($response, $request);
return $this->createTestResponse($response, $request);
}

/**
Expand Down
19 changes: 0 additions & 19 deletions src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Throwable;

abstract class TestCase extends BaseTestCase
{
Expand Down Expand Up @@ -42,8 +41,6 @@ public function createApplication()
*/
protected function setUp(): void
{
static::$latestResponse = null;

$this->setUpTheTestEnvironment();
}

Expand All @@ -57,20 +54,6 @@ protected function refreshApplication()
$this->app = $this->createApplication();
}

/**
* {@inheritdoc}
*/
protected function transformException(Throwable $error): Throwable
{
$response = static::$latestResponse ?? null;

if (! is_null($response)) {
$response->transformNotSuccessfulException($error);
}

return $error;
}

/**
* Clean up the testing environment before the next test.
*
Expand All @@ -90,8 +73,6 @@ protected function tearDown(): void
*/
public static function tearDownAfterClass(): void
{
static::$latestResponse = null;

static::tearDownAfterClassUsingTestCase();
}
}
Loading

0 comments on commit 8ce249a

Please sign in to comment.