Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix TestResponseAssert docblock #51942

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/Illuminate/Testing/TestResponseAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ public static function withResponse(TestResponse $response): self
/**
* Pass method calls to the Assert class and decorate the exception message.
*
* @param string $method
* @param array $args
* @return mixed
* @param string $name
* @param array $arguments
* @return void
*
* @throws \PHPUnit\Framework\ExpectationFailedException
*/
public function __call($name, $arguments)
{
try {
return Assert::$name(...$arguments);
Assert::$name(...$arguments);
} catch (ExpectationFailedException $e) {
throw $this->injectResponseContext($e);
}
Expand All @@ -49,20 +51,22 @@ public function __call($name, $arguments)
/**
* Pass static method calls to the Assert class.
*
* @param string $method
* @param array $args
* @return mixed
* @param string $name
* @param array $arguments
* @return void
*
* @throws \PHPUnit\Framework\ExpectationFailedException
*/
public static function __callStatic($name, $arguments)
{
return Assert::$name(...$arguments);
Assert::$name(...$arguments);
}

/**
* Inject additional context from the response into the exception message.
*
* @param \ExpectationFailedException $exception
* @return \ExpectationFailedException
* @param \PHPUnit\Framework\ExpectationFailedException $exception
* @return \PHPUnit\Framework\ExpectationFailedException
*/
protected function injectResponseContext($exception)
{
Expand Down Expand Up @@ -93,8 +97,8 @@ protected function injectResponseContext($exception)
* Append an exception to the message of another exception.
*
* @param \Throwable $exceptionToAppend
* @param \Throwable $exception
* @return \Throwable
* @param \PHPUnit\Framework\ExpectationFailedException $exception
* @return \PHPUnit\Framework\ExpectationFailedException
*/
protected function appendExceptionToException($exceptionToAppend, $exception)
{
Expand All @@ -119,9 +123,9 @@ protected function appendExceptionToException($exceptionToAppend, $exception)
* Append errors to an exception message.
*
* @param array $errors
* @param \Throwable $exception
* @param \PHPUnit\Framework\ExpectationFailedException $exception
* @param bool $json
* @return \Throwable
* @return \PHPUnit\Framework\ExpectationFailedException
*/
protected function appendErrorsToException($errors, $exception, $json = false)
{
Expand All @@ -147,8 +151,8 @@ protected function appendErrorsToException($errors, $exception, $json = false)
* Append a message to an exception.
*
* @param string $message
* @param \Throwable $exception
* @return \Throwable
* @param \PHPUnit\Framework\ExpectationFailedException $exception
* @return \PHPUnit\Framework\ExpectationFailedException
*/
protected function appendMessageToException($message, $exception)
{
Expand Down