public function testCustomConfigurationPassed() { $configuration = new GenericConfiguration(); $configuration->setLocale('nl-be')->setClientName('test')->setRequest(new Request()); $request = RequestFactory::createRequest($configuration); $this->assertSame($configuration, \PHPUnit_Framework_Assert::readAttribute($request, 'configuration')); }
/** * @expectedException LogicException */ public function testInvalidRequestFactoryCallbackReturnValue() { $conf = new GenericConfiguration(); $conf->setRequestFactory(function ($request) { return new \stdClass(); }); RequestFactory::createRequest($conf); }
/** * Runs the given operation * * @param OperationInterface $operation The operation object * @param ConfigurationInterface $configuration The configuration object * * @return mixed */ public function runOperation(OperationInterface $operation) { $configuration = @is_null($configuration) ? $this->configuration : $configuration; if (true === is_null($configuration)) { throw new \Exception('No configuration passed.'); } $requestObject = RequestFactory::createRequest($configuration); $response = $requestObject->perform($operation); if ($this->configuration->getResponseType() == 'object') { return json_decode($response); } else { return json_decode($response, true); } }