public function it_can_generate_an_image_response(ResponseInterface $response, File $file, ImageInterface $image) { $responseMock = 'i-am-not-really-an-image'; $fileName = FileNameValue::get('image.png'); $fileMimeType = MimeTypeValue::get('image/png'); $response->offsetGet('image')->willReturn($image); $response->offsetGet('file')->willReturn($file); $file->getName()->willReturn($fileName); $file->getMimeType()->willReturn($fileMimeType); $this->imageEditor->output($file, $image)->willReturn($responseMock); $httpResponse = $this->generateResponse($response); $httpResponse->shouldHaveType(HttpResponse::class); $httpResponse->getStatusCode()->shouldReturn(200); $httpResponse->getHeaderLine('Content-Type')->shouldReturn($fileMimeType->toString()); $httpResponse->getBody()->getContents()->shouldReturn($responseMock); }
public function it_can_generate_a_response(ResponseInterface $response, File $file) { $fileName = 'file.ext'; $mimeType = 'text/xml'; $file->getStream()->willReturn(tmpfile()); $file->getName()->willReturn(FileNameValue::get($fileName)); $file->getMimeType()->willReturn(MimeTypeValue::get($mimeType)); $response->offsetGet('data')->willReturn($file); $httpResponse = $this->generateResponse($response); $httpResponse->getHeaderLine('Content-Type')->shouldReturn($mimeType); $httpResponse->getHeaderLine('Content-Disposition')->shouldReturn('attachment; filename="' . $fileName . '"'); }
public function it_can_generate_a_response(ResponseInterface $response) { $tokenUuid = Uuid::uuid4()->toString(); $passCode = bin2hex(random_bytes(20)); $expires = (new \DateTimeImmutable('+42 seconds'))->format('Y-m-d H:i:s'); $response->getResponseName()->willReturn(RefreshTokenHandler::MESSAGE); $response->offsetGet('token')->willReturn($tokenUuid); $response->offsetGet('pass_code')->willReturn($passCode); $response->offsetGet('expires')->willReturn($expires); $httpResponse = $this->generateResponse($response); $httpResponse->shouldHaveType(\Psr\Http\Message\ResponseInterface::class); }