public function testSettersAndGetters() { $clientInfo = $this->getMock('InoOicClient\\Client\\ClientInfo'); $grantType = 'authorization_code'; $code = '1234'; $request = new Request(); $request->setClientInfo($clientInfo); $request->setGrantType($grantType); $request->setCode($code); $this->assertSame($clientInfo, $request->getClientInfo()); $this->assertSame($grantType, $request->getGrantType()); $this->assertSame($code, $request->getCode()); }
/** * Builds a HTTP request based on the token request entity. * * @param Request $request * @param Http\Request $httpRequest * @return Http\Request */ public function buildHttpRequest(Request $request, Http\Request $httpRequest = null) { if (null === $httpRequest) { $httpRequest = new Http\Request(); } $clientInfo = $request->getClientInfo(); if (!$clientInfo instanceof ClientInfo) { throw new Exception\InvalidRequestException('No client info in request'); } $endpointUri = $clientInfo->getTokenEndpoint(); $httpRequest->setUri($endpointUri); $httpRequest->setMethod('POST'); $httpRequest->getPost()->fromArray(array(Param::CLIENT_ID => $clientInfo->getClientId(), Param::REDIRECT_URI => $clientInfo->getRedirectUri(), Param::GRANT_TYPE => $request->getGrantType(), Param::CODE => $request->getCode())); $headers = array_merge($this->defaultHeaders, $this->options->get(self::OPT_HEADERS, array())); $httpRequest->getHeaders()->addHeaders($headers); $authenticator = $this->getClientAuthenticatorFactory()->createAuthenticator($clientInfo); $authenticator->configureHttpRequest($httpRequest); return $httpRequest; }