private function getGeneratorForResponse(ResponseInterface $response) : GeneratorInterface { $name = $response->getResponseName(); foreach ($this->getRequestedContentTypes($response) as $contentType) { if ($this->hasGenerator($name, $contentType)) { return $this->getGenerator($name, $contentType); } } throw new \OutOfBoundsException(sprintf('No generator registered for %s with content type: %s', $name, $response->getContentType() ?? '(none)')); }
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); }
public function it_can_generate_a_response(ResponseInterface $response) { $response->getResponseName()->willReturn(LogoutHandler::MESSAGE); $httpResponse = $this->generateResponse($response); $httpResponse->shouldHaveType(\Psr\Http\Message\ResponseInterface::class); }