Skip to content

Commit

Permalink
Fix TestResponseAssert docblock (#51942)
Browse files Browse the repository at this point in the history
  • Loading branch information
seriquynh authored Jun 28, 2024
1 parent 639f729 commit c307abc
Showing 1 changed file with 20 additions and 16 deletions.
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

0 comments on commit c307abc

Please sign in to comment.