Exemplo n.º 1
0
 /**
  * Get the request object
  * @param $fwRequest - constructed using a fw adapted object
  * @return Request $request
  */
 public function getRequest($fwRequest = null)
 {
     if (!$this->request instanceof Request) {
         $this->request = Request::create($fwRequest, $this->config->getRegisteredRequestAdapterClasses());
     }
     return $this->request;
 }
Exemplo n.º 2
0
 /**
  * Set up the HTTP manager
  * @param $request
  * @param $response
  * @param Configuration $config
  */
 public function setUpHttp($request, $response, Configuration $config)
 {
     $this->setRequest(Request::create($request, $config->getRegisteredRequestAdapterClasses()));
     $this->setResponse(Response::create($response, $config->getRegisteredResponseAdapterClasses()));
 }
Exemplo n.º 3
0
 public function testRegisterRequestAdapterClasses()
 {
     $config = new Configuration();
     $class = 'DrestCommon\\Request\\Adapter\\ZendFramework2';
     $config->registerRequestAdapterClass($class);
     $sizeofClasses = sizeof($config->getRegisteredRequestAdapterClasses());
     $this->assertContains($class, $config->getRegisteredRequestAdapterClasses());
     // Adding it again shouldn't increase the class count
     $config->registerRequestAdapterClass($class);
     $this->assertEquals($sizeofClasses, sizeof($config->getRegisteredRequestAdapterClasses()));
     // Remove the entry
     $config->unregisterRequestAdapterClass($class);
     $this->assertNotContains($class, $config->getRegisteredRequestAdapterClasses());
     // Check the count has reduced by one
     $this->assertEquals($sizeofClasses - 1, sizeof($config->getRegisteredRequestAdapterClasses()));
 }