public function testConvert()
 {
     $statusCode = 203;
     $content = 'foo';
     $headers = array('a' => '1', 'b' => '2');
     $symfonyResponse = new SymfonyResponse($content, $statusCode, $headers);
     $response = new Response($statusCode, $content, array_merge($headers, array('cache-control' => $symfonyResponse->headers->get('cache-control'), 'date' => $symfonyResponse->headers->get('date'))));
     $converter = new SymfonyHttpFoundationResponseConverter();
     $this->assertEquals($response, $converter->convert($symfonyResponse));
 }
示例#2
0
 /**
  * @return Http\Response
  */
 public function request(Request $request)
 {
     $uri = $request->getUri();
     $requestConverter = new SymfonyHttpFoundationRequestConverter();
     $symfonyRequest = $requestConverter->convert($request);
     if ($uri === '/oauth/token') {
         $response = $this->server->token($symfonyRequest);
     } elseif ($uri === '/resource') {
         $response = $this->server->resource($symfonyRequest, function () {
             $response = new Response();
             $response->headers->set('content-type', 'text/plain');
             $response->setContent('My resource!');
             return $response;
         });
     } else {
         throw new \Exception('Invalid request.');
     }
     $responseConverter = new SymfonyHttpFoundationResponseConverter();
     return $responseConverter->convert($response);
 }