Ejemplo n.º 1
0
 /**
  * Get the response object
  * @return Response $response
  */
 public function getResponse()
 {
     if (!$this->response instanceof Response) {
         $this->response = Response::create();
     }
     return $this->response;
 }
Ejemplo n.º 2
0
 public function testResponseDocumentToString()
 {
     $httpString = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nAccept: application/json\r\n\r\n\r\n<html>\r\n<body>\r\n    This is a test document\r\n</body>\r\n</html>";
     $symResponse = new HttpFoundation\Response($httpString);
     $response = Response::create($symResponse, array('DrestCommon\\Response\\Adapter\\Symfony2'));
     ob_start();
     ob_get_contents();
     echo $response->__toString();
     $actual = ob_get_contents();
     ob_end_clean();
     $this->assertEquals($httpString, $actual);
 }
Ejemplo n.º 3
0
 public function testResponseDocumentToString()
 {
     $httpHeaders = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nAccept: application/json\r\n\r\n";
     $httpString = "<html>\r\n<body>\r\n    This is a test document\r\n</body>\r\n</html>";
     $zf2Response = \Zend\Http\PhpEnvironment\Response::fromString($httpHeaders . $httpString);
     $response = Response::create($zf2Response, array('DrestCommon\\Response\\Adapter\\ZendFramework2'));
     ob_start();
     ob_get_contents();
     echo $response;
     $actual = ob_get_contents();
     ob_end_clean();
     $this->assertEquals($httpString, $actual);
 }
Ejemplo n.º 4
0
 /**
  * Get the response object
  * @param $fwResponse - constructed using a fw adapted object
  * @return Response $response
  */
 public function getResponse($fwResponse = null)
 {
     if (!$this->response instanceof Response) {
         $this->response = Response::create($fwResponse, $this->config->getRegisteredResponseAdapterClasses());
     }
     return $this->response;
 }
Ejemplo n.º 5
0
 /**
  * Get an instance of the response object with a symfony adapter used
  * @return Response;
  */
 public static function getGuzzleAdapterResponse()
 {
     $guzResponse = new GuzzleResponse(200);
     $response = Response::create($guzResponse, array('DrestCommon\\Response\\Adapter\\Guzzle'));
     return $response;
 }
Ejemplo n.º 6
0
 /**
  * Create an instance of client response and wrap the representation object
  */
 public function __construct(AbstractRepresentation $representation, $response_object = null)
 {
     $this->representation = $representation;
     parent::__construct($response_object);
 }
Ejemplo n.º 7
0
 public function testStaticCreateResponse()
 {
     $response = Response::create();
     // Ensure default response object creates a symfony response
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response->getResponse());
 }