diff --git a/src/Testing/Laravel/Contracts/Routing/ResponseFactoryAssert.php b/src/Testing/Laravel/Contracts/Routing/ResponseFactoryAssert.php new file mode 100644 index 00000000..623c1a6e --- /dev/null +++ b/src/Testing/Laravel/Contracts/Routing/ResponseFactoryAssert.php @@ -0,0 +1,424 @@ + $make + * @param array $noContent + * @param array $view + * @param array $json + * @param array $jsonp + * @param array $stream + * @param array $streamDownload + * @param array $download + * @param array $file + * @param array $redirectTo + * @param array $redirectToRoute + * @param array $redirectToAction + * @param array $redirectGuest + * @param array $redirectToIntended + */ + public function __construct( + array $make = [], + array $noContent = [], + array $view = [], + array $json = [], + array $jsonp = [], + array $stream = [], + array $streamDownload = [], + array $download = [], + array $file = [], + array $redirectTo = [], + array $redirectToRoute = [], + array $redirectToAction = [], + array $redirectGuest = [], + array $redirectToIntended = [], + ) { + $this->setExpectations(ResponseFactoryMakeExpectation::class, array_values(array_filter($make))); + $this->setExpectations(ResponseFactoryNoContentExpectation::class, array_values(array_filter($noContent))); + $this->setExpectations(ResponseFactoryViewExpectation::class, array_values(array_filter($view))); + $this->setExpectations(ResponseFactoryJsonExpectation::class, array_values(array_filter($json))); + $this->setExpectations(ResponseFactoryJsonpExpectation::class, array_values(array_filter($jsonp))); + $this->setExpectations(ResponseFactoryStreamExpectation::class, array_values(array_filter($stream))); + $this->setExpectations( + ResponseFactoryStreamDownloadExpectation::class, + array_values(array_filter($streamDownload)) + ); + $this->setExpectations(ResponseFactoryDownloadExpectation::class, array_values(array_filter($download))); + $this->setExpectations(ResponseFactoryFileExpectation::class, array_values(array_filter($file))); + $this->setExpectations(ResponseFactoryRedirectToExpectation::class, array_values(array_filter($redirectTo))); + $this->setExpectations( + ResponseFactoryRedirectToRouteExpectation::class, + array_values(array_filter($redirectToRoute)) + ); + $this->setExpectations( + ResponseFactoryRedirectToActionExpectation::class, + array_values(array_filter($redirectToAction)) + ); + $this->setExpectations( + ResponseFactoryRedirectGuestExpectation::class, + array_values(array_filter($redirectGuest)) + ); + $this->setExpectations( + ResponseFactoryRedirectToIntendedExpectation::class, + array_values(array_filter($redirectToIntended)) + ); + } + + /** + * Create a new response instance. + * + * @param array|string $content + * @param int $status + * @return Response + */ + public function make($content = '', $status = 200, array $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryMakeExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->content, $content, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $content, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new "no content" response. + * + * @param int $status + * @return Response + */ + public function noContent($status = 204, array $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryNoContentExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new response for a given view. + * + * @param string|array $view + * @param array $data + * @param int $status + * @return Response + */ + public function view($view, $data = [], $status = 200, array $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryViewExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->view, $view, $message); + Assert::assertEquals($expectation->data, $data, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $view, $data, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new JSON response instance. + * + * @param mixed $data + * @param int $status + * @param int $options + * @return JsonResponse + */ + public function json($data = [], $status = 200, array $headers = [], $options = 0) + { + $expectation = $this->getExpectation(ResponseFactoryJsonExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->data, $data, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->options, $options, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $data, $status, $headers, $options, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new JSONP response instance. + * + * @param string $callback + * @param mixed $data + * @param int $status + * @param int $options + * @return JsonResponse + */ + public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0) + { + $expectation = $this->getExpectation(ResponseFactoryJsonpExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->callback, $callback, $message); + Assert::assertEquals($expectation->data, $data, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->options, $options, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $callback, $data, $status, $headers, $options, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new streamed response instance. + * + * @param callable $callback + * @param int $status + * @return StreamedResponse + */ + public function stream($callback, $status = 200, array $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryStreamExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $callback, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new streamed response instance as a file download. + * + * @param callable $callback + * @param string|null $name + * @param string|null $disposition + * @return StreamedResponse + */ + public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment') + { + $expectation = $this->getExpectation(ResponseFactoryStreamDownloadExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->name, $name, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->disposition, $disposition, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $callback, $name, $headers, $disposition, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new file download response. + * + * @param SplFileInfo|string $file + * @param string|null $name + * @param string|null $disposition + * @return BinaryFileResponse + */ + public function download($file, $name = null, array $headers = [], $disposition = 'attachment') + { + $expectation = $this->getExpectation(ResponseFactoryDownloadExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->file, $file, $message); + Assert::assertEquals($expectation->name, $name, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->disposition, $disposition, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $file, $name, $headers, $disposition, $expectation); + } + + return $expectation->return; + } + + /** + * Return the raw contents of a binary file. + * + * @param SplFileInfo|string $file + * @return BinaryFileResponse + */ + public function file($file, array $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryFileExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->file, $file, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $file, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new redirect response to the given path. + * + * @param string $path + * @param int $status + * @param array $headers + * @param bool|null $secure + * @return RedirectResponse + */ + public function redirectTo($path, $status = 302, $headers = [], $secure = null) + { + $expectation = $this->getExpectation(ResponseFactoryRedirectToExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->path, $path, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->secure, $secure, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $path, $status, $headers, $secure, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new redirect response to a named route. + * + * @param string $route + * @param mixed $parameters + * @param int $status + * @param array $headers + * @return RedirectResponse + */ + public function redirectToRoute($route, $parameters = [], $status = 302, $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryRedirectToRouteExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->route, $route, $message); + Assert::assertEquals($expectation->parameters, $parameters, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $route, $parameters, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new redirect response to a controller action. + * + * @param string $action + * @param mixed $parameters + * @param int $status + * @param array $headers + * @return RedirectResponse + */ + public function redirectToAction($action, $parameters = [], $status = 302, $headers = []) + { + $expectation = $this->getExpectation(ResponseFactoryRedirectToActionExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->action, $action, $message); + Assert::assertEquals($expectation->parameters, $parameters, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $action, $parameters, $status, $headers, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new redirect response, while putting the current URL in the session. + * + * @param string $path + * @param int $status + * @param array $headers + * @param bool|null $secure + * @return RedirectResponse + */ + public function redirectGuest($path, $status = 302, $headers = [], $secure = null) + { + $expectation = $this->getExpectation(ResponseFactoryRedirectGuestExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->path, $path, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->secure, $secure, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $path, $status, $headers, $secure, $expectation); + } + + return $expectation->return; + } + + /** + * Create a new redirect response to the previously intended location. + * + * @param string $default + * @param int $status + * @param array $headers + * @param bool|null $secure + * @return RedirectResponse + */ + public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null) + { + $expectation = $this->getExpectation(ResponseFactoryRedirectToIntendedExpectation::class); + $message = $this->getDebugMessage(); + + Assert::assertEquals($expectation->default, $default, $message); + Assert::assertEquals($expectation->status, $status, $message); + Assert::assertEquals($expectation->headers, $headers, $message); + Assert::assertEquals($expectation->secure, $secure, $message); + + if (is_callable($expectation->hook)) { + call_user_func($expectation->hook, $default, $status, $headers, $secure, $expectation); + } + + return $expectation->return; + } +} diff --git a/src/Testing/Laravel/Contracts/Routing/ResponseFactoryDownloadExpectation.php b/src/Testing/Laravel/Contracts/Routing/ResponseFactoryDownloadExpectation.php new file mode 100644 index 00000000..b1e21fae --- /dev/null +++ b/src/Testing/Laravel/Contracts/Routing/ResponseFactoryDownloadExpectation.php @@ -0,0 +1,23 @@ +createUrl($path, $extra, $secure); - } - - public function secure($path, $parameters = []): string - { - return $this->to($path, $parameters); - } - - public function asset($path, $secure = null): string - { - return $this->to('assets/' . $path, [], $secure); - } - - public function route($name, $parameters = [], $absolute = true): string - { - return $this->createUrl('route/' . $name, $parameters, $absolute); - } - - public function action($action, $parameters = [], $absolute = true): string - { - $actionString = is_array($action) ? implode('-', $action) : $action; - - return $this->createUrl('action/' . $actionString, $parameters, $absolute); - } - - public function getRootControllerNamespace(): string - { - return $this->controllerNamespace; - } - - public function setRootControllerNamespace($rootNamespace): self - { - $this->controllerNamespace = $rootNamespace; - - return $this; - } - - protected function createUrl( - string $path, - array $parameters = [], - mixed $secure = null, - bool $absolute = true - ): string { - $paramsString = $parameters === [] - ? '' - : ('?' . http_build_query($parameters)); - $fullPath = '/' . $path . $paramsString; - - if ($absolute === false) { - return $fullPath; - } - - if ($secure === true) { - return 'https://localhost' . $fullPath; - } - - return 'http://localhost/' . $path . $paramsString; - } -} diff --git a/tests/Feature/Testing/Laravel/Contracts/Routing/ResponseFactoryAssertTest.php b/tests/Feature/Testing/Laravel/Contracts/Routing/ResponseFactoryAssertTest.php new file mode 100644 index 00000000..15be6f93 --- /dev/null +++ b/tests/Feature/Testing/Laravel/Contracts/Routing/ResponseFactoryAssertTest.php @@ -0,0 +1,682 @@ + 'stream'; + return [ + new AssertExpectationEntity( + methodName: 'make', + createAssert: static fn () => new ResponseFactoryAssert(make: [ + new ResponseFactoryMakeExpectation(return: $response), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->make(), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'make', + createAssert: static fn () => new ResponseFactoryAssert(make: [ + new ResponseFactoryMakeExpectation(return: $response, content: 'Content'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->make(content: 'Content'), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'make', + createAssert: static fn () => new ResponseFactoryAssert(make: [ + new ResponseFactoryMakeExpectation(return: $response, content: 'Content', status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->make(content: 'Content', status: 203), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'make', + createAssert: static fn () => new ResponseFactoryAssert(make: [ + new ResponseFactoryMakeExpectation(return: $response, content: 'Content', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->make( + content: 'Content', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'noContent', + createAssert: static fn () => new ResponseFactoryAssert(noContent: [ + new ResponseFactoryNoContentExpectation(return: $response), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->noContent(), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'noContent', + createAssert: static fn () => new ResponseFactoryAssert(noContent: [ + new ResponseFactoryNoContentExpectation(return: $response, status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->noContent(status: 203), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'noContent', + createAssert: static fn () => new ResponseFactoryAssert(noContent: [ + new ResponseFactoryNoContentExpectation(return: $response, status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->noContent(status: 203, headers: [ + 'header' => ['value'], + ]), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'view', + createAssert: static fn () => new ResponseFactoryAssert(view: [ + new ResponseFactoryViewExpectation(return: $response, view: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->view(view: 'test'), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'view', + createAssert: static fn () => new ResponseFactoryAssert(view: [ + new ResponseFactoryViewExpectation(return: $response, view: 'test', status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->view(view: 'test', status: 203), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'view', + createAssert: static fn () => new ResponseFactoryAssert(view: [ + new ResponseFactoryViewExpectation(return: $response, view: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->view(view: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + checkResult: true, + expectedResult: $response + ), + new AssertExpectationEntity( + methodName: 'json', + createAssert: static fn () => new ResponseFactoryAssert(json: [ + new ResponseFactoryJsonExpectation(return: $jsonResponse, data: ['test']), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->json(data: ['test']), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'json', + createAssert: static fn () => new ResponseFactoryAssert(json: [ + new ResponseFactoryJsonExpectation(return: $jsonResponse, data: ['test'], status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->json(data: ['test'], status: 203), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'json', + createAssert: static fn () => new ResponseFactoryAssert(json: [ + new ResponseFactoryJsonExpectation(return: $jsonResponse, data: ['test'], status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->json(data: ['test'], status: 203, headers: [ + 'header' => ['value'], + ]), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'jsonp', + createAssert: static fn () => new ResponseFactoryAssert(jsonp: [ + new ResponseFactoryJsonpExpectation(return: $jsonResponse, callback: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->jsonp(callback: 'test'), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'jsonp', + createAssert: static fn () => new ResponseFactoryAssert(jsonp: [ + new ResponseFactoryJsonpExpectation(return: $jsonResponse, callback: 'test', status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->jsonp(callback: 'test', status: 203), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'jsonp', + createAssert: static fn () => new ResponseFactoryAssert(jsonp: [ + new ResponseFactoryJsonpExpectation(return: $jsonResponse, callback: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->jsonp( + callback: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $jsonResponse + ), + new AssertExpectationEntity( + methodName: 'stream', + createAssert: static fn () => new ResponseFactoryAssert(stream: [ + new ResponseFactoryStreamExpectation(return: $streamResponse, hook: $assertStreamCallback), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->stream(callback: $streamCallback), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'stream', + createAssert: static fn () => new ResponseFactoryAssert(stream: [ + new ResponseFactoryStreamExpectation( + return: $streamResponse, + status: 203, + hook: $assertStreamCallback + ), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->stream( + callback: $streamCallback, + status: 203 + ), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'stream', + createAssert: static fn () => new ResponseFactoryAssert(stream: [ + new ResponseFactoryStreamExpectation(return: $streamResponse, status: 203, headers: [ + 'header' => ['value'], + ], hook: $assertStreamCallback), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->stream( + callback: $streamCallback, + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'streamDownload', + createAssert: static fn () => new ResponseFactoryAssert(streamDownload: [ + new ResponseFactoryStreamDownloadExpectation(return: $streamResponse, hook: $assertStreamCallback), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->streamDownload(callback: $streamCallback), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'streamDownload', + createAssert: static fn () => new ResponseFactoryAssert(streamDownload: [ + new ResponseFactoryStreamDownloadExpectation( + return: $streamResponse, + name: 'test', + hook: $assertStreamCallback + ), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->streamDownload( + callback: $streamCallback, + name: 'test' + ), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'streamDownload', + createAssert: static fn () => new ResponseFactoryAssert(streamDownload: [ + new ResponseFactoryStreamDownloadExpectation(return: $streamResponse, name: 'test', headers: [ + 'header' => ['value'], + ], hook: $assertStreamCallback), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->streamDownload( + callback: $streamCallback, + name: 'test', + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'streamDownload', + createAssert: static fn () => new ResponseFactoryAssert(streamDownload: [ + new ResponseFactoryStreamDownloadExpectation(return: $streamResponse, name: 'test', headers: [ + 'header' => ['value'], + ], disposition: 'inline', hook: $assertStreamCallback), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->streamDownload( + callback: $streamCallback, + name: 'test', + headers: [ + 'header' => ['value'], + ], + disposition: 'inline' + ), + checkResult: true, + expectedResult: $streamResponse + ), + new AssertExpectationEntity( + methodName: 'download', + createAssert: static fn () => new ResponseFactoryAssert(download: [ + new ResponseFactoryDownloadExpectation(return: $binaryFileResponse, file: 'file'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->download(file: 'file'), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'download', + createAssert: static fn () => new ResponseFactoryAssert(download: [ + new ResponseFactoryDownloadExpectation(return: $binaryFileResponse, file: 'file', name: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->download(file: 'file', name: 'test'), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'download', + createAssert: static fn () => new ResponseFactoryAssert(download: [ + new ResponseFactoryDownloadExpectation(return: $binaryFileResponse, file: 'file', name: 'test', headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->download( + file: 'file', + name: 'test', + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'download', + createAssert: static fn () => new ResponseFactoryAssert(download: [ + new ResponseFactoryDownloadExpectation(return: $binaryFileResponse, file: 'file', name: 'test', headers: [ + 'header' => ['value'], + ], disposition: 'inline'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->download( + file: 'file', + name: 'test', + headers: [ + 'header' => ['value'], + ], + disposition: 'inline' + ), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'file', + createAssert: static fn () => new ResponseFactoryAssert(file: [ + new ResponseFactoryFileExpectation(return: $binaryFileResponse, file: 'file'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->file(file: 'file'), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'file', + createAssert: static fn () => new ResponseFactoryAssert(file: [ + new ResponseFactoryFileExpectation(return: $binaryFileResponse, file: 'file', headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->file(file: 'file', headers: [ + 'header' => ['value'], + ]), + checkResult: true, + expectedResult: $binaryFileResponse + ), + new AssertExpectationEntity( + methodName: 'redirectTo', + createAssert: static fn () => new ResponseFactoryAssert(redirectTo: [ + new ResponseFactoryRedirectToExpectation(return: $redirectResponse, path: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectTo(path: 'test'), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectTo', + createAssert: static fn () => new ResponseFactoryAssert(redirectTo: [ + new ResponseFactoryRedirectToExpectation(return: $redirectResponse, path: 'test', status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectTo(path: 'test', status: 203), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectTo', + createAssert: static fn () => new ResponseFactoryAssert(redirectTo: [ + new ResponseFactoryRedirectToExpectation(return: $redirectResponse, path: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectTo( + path: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectTo', + createAssert: static fn () => new ResponseFactoryAssert(redirectTo: [ + new ResponseFactoryRedirectToExpectation(return: $redirectResponse, path: 'test', status: 203, headers: [ + 'header' => ['value'], + ], secure: true), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectTo( + path: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ], + secure: true + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToRoute', + createAssert: static fn () => new ResponseFactoryAssert(redirectToRoute: [ + new ResponseFactoryRedirectToRouteExpectation(return: $redirectResponse, route: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToRoute(route: 'test'), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToRoute', + createAssert: static fn () => new ResponseFactoryAssert(redirectToRoute: [ + new ResponseFactoryRedirectToRouteExpectation( + return: $redirectResponse, + route: 'test', + status: 203 + ), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToRoute(route: 'test', status: 203), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToRoute', + createAssert: static fn () => new ResponseFactoryAssert(redirectToRoute: [ + new ResponseFactoryRedirectToRouteExpectation(return: $redirectResponse, route: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToRoute( + route: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToAction', + createAssert: static fn () => new ResponseFactoryAssert(redirectToAction: [ + new ResponseFactoryRedirectToActionExpectation(return: $redirectResponse, action: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToAction(action: 'test'), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToAction', + createAssert: static fn () => new ResponseFactoryAssert(redirectToAction: [ + new ResponseFactoryRedirectToActionExpectation(return: $redirectResponse, action: 'test', parameters: [ + 'param' => true, + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToAction( + action: 'test', + parameters: [ + 'param' => true, + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToAction', + createAssert: static fn () => new ResponseFactoryAssert(redirectToAction: [ + new ResponseFactoryRedirectToActionExpectation(return: $redirectResponse, action: 'test', parameters: [ + 'param' => true, + ], status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToAction( + action: 'test', + parameters: [ + 'param' => true, + ], + status: 203 + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToAction', + createAssert: static fn () => new ResponseFactoryAssert(redirectToAction: [ + new ResponseFactoryRedirectToActionExpectation(return: $redirectResponse, action: 'test', parameters: [ + 'param' => true, + ], status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToAction( + action: 'test', + parameters: [ + 'param' => true, + ], + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectGuest', + createAssert: static fn () => new ResponseFactoryAssert(redirectGuest: [ + new ResponseFactoryRedirectGuestExpectation(return: $redirectResponse, path: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectGuest(path: 'test'), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectGuest', + createAssert: static fn () => new ResponseFactoryAssert(redirectGuest: [ + new ResponseFactoryRedirectGuestExpectation(return: $redirectResponse, path: 'test', status: 203), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectGuest(path: 'test', status: 203), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectGuest', + createAssert: static fn () => new ResponseFactoryAssert(redirectGuest: [ + new ResponseFactoryRedirectGuestExpectation(return: $redirectResponse, path: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectGuest( + path: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectGuest', + createAssert: static fn () => new ResponseFactoryAssert(redirectGuest: [ + new ResponseFactoryRedirectGuestExpectation(return: $redirectResponse, path: 'test', status: 203, headers: [ + 'header' => ['value'], + ], secure: true), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectGuest( + path: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ], + secure: true + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToIntended', + createAssert: static fn () => new ResponseFactoryAssert(redirectToIntended: [ + new ResponseFactoryRedirectToIntendedExpectation(return: $redirectResponse), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToIntended(), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToIntended', + createAssert: static fn () => new ResponseFactoryAssert(redirectToIntended: [ + new ResponseFactoryRedirectToIntendedExpectation(return: $redirectResponse, default: 'test'), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToIntended(default: 'test'), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToIntended', + createAssert: static fn () => new ResponseFactoryAssert(redirectToIntended: [ + new ResponseFactoryRedirectToIntendedExpectation( + return: $redirectResponse, + default: 'test', + status: 203 + ), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToIntended( + default: 'test', + status: 203 + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToIntended', + createAssert: static fn () => new ResponseFactoryAssert(redirectToIntended: [ + new ResponseFactoryRedirectToIntendedExpectation(return: $redirectResponse, default: 'test', status: 203, headers: [ + 'header' => ['value'], + ]), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToIntended( + default: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ] + ), + checkResult: true, + expectedResult: $redirectResponse + ), + new AssertExpectationEntity( + methodName: 'redirectToIntended', + createAssert: static fn () => new ResponseFactoryAssert(redirectToIntended: [ + new ResponseFactoryRedirectToIntendedExpectation(return: $redirectResponse, default: 'test', status: 203, headers: [ + 'header' => ['value'], + ], secure: true), + ]), + call: static fn (ResponseFactoryAssert $assert) => $assert->redirectToIntended( + default: 'test', + status: 203, + headers: [ + 'header' => ['value'], + ], + secure: true + ), + checkResult: true, + expectedResult: $redirectResponse + ), + ]; + } + + protected function createEmptyAssert(): AbstractExpectationCallsMap + { + return new ResponseFactoryAssert(); + } +}