Esempio n. 1
0
 /**
  * Applies a responsetransformer
  *
  * @param mixed                  $response      The response of the request
  * @param ConfigurationInterface $configuration The configurationobject
  *
  * @return mixed
  */
 protected function applyResponseTransformer($response, ConfigurationInterface $configuration)
 {
     if (true === is_null($configuration->getResponseTransformer())) {
         return $response;
     }
     $responseTransformer = ResponseTransformerFactory::createResponseTransformer($configuration);
     return $responseTransformer->transform($response);
 }
 public function testCallback()
 {
     $responseTransformer = $this->getMock('\\ApaiIO\\ResponseTransformer\\ResponseTransformerInterface');
     $callback = $this->getMock(__NAMESPACE__ . '\\CallableClass', array('foo'));
     $callback->expects($this->once())->method('foo')->with($this->isInstanceOf('\\ApaiIO\\ResponseTransformer\\ResponseTransformerInterface'))->will($this->returnValue($responseTransformer));
     $configuration = $this->getMock('\\ApaiIO\\Configuration\\ConfigurationInterface', array('getRequest', 'getRequestFactory', 'getCountry', 'getAccessKey', 'getSecretKey', 'getAssociateTag', 'getResponseTransformer', 'getResponseTransformerFactory'));
     $configuration->expects($this->once())->method('getResponseTransformer')->will($this->returnValue($responseTransformer));
     $configuration->expects($this->once())->method('getResponseTransformerFactory')->will($this->returnValue(array($callback, 'foo')));
     ResponseTransformerFactory::createResponseTransformer($configuration);
 }
Esempio n. 3
0
 /**
  * @expectedException LogicException
  */
 public function testInvalidRequestFactoryCallbackReturnValue()
 {
     $conf = new GenericConfiguration();
     $conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\XmlToDomDocument');
     $conf->setResponseTransformerFactory(function ($response) {
         return new \stdClass();
     });
     ResponseTransformerFactory::createResponseTransformer($conf);
 }