public function setUp() { $this->_mockSigner = ehough_mockery_Mockery::mock('ehough_coauthor_spi_v1_SignerInterface'); $this->_mockClientCredentials = new ehough_coauthor_api_v1_Credentials('id', 'secret'); $this->_mockTemporaryCredentials = new ehough_coauthor_api_v1_Credentials('id2', 'secret2'); $this->_mockServer = ehough_mockery_Mockery::mock('ehough_coauthor_api_v1_AbstractServer'); $this->_mockHttpClient = ehough_mockery_Mockery::mock('ehough_shortstop_api_HttpClientInterface'); $this->_mockServer->shouldReceive('getTemporaryCredentialsEndpoint')->andReturn(new ehough_curly_Url('http://abc.com/a/f/2.php?x=z')); $this->_mockServer->shouldReceive('getTokensEndpoint')->andReturn(new ehough_curly_Url('http://xez.net/w2/d/z.php?a=b')); $this->_mockHttpResponse = new ehough_shortstop_api_HttpResponse(); $this->_mockHttpResponse->setStatusCode(200); $entity = new ehough_shortstop_api_HttpEntity(); $entity->setContent('oauth_token=token&oauth_token_secret=secrettt'); $this->_mockHttpResponse->setEntity($entity); $this->_sut = new ehough_coauthor_impl_v1_DefaultRemoteCredentialsFetcher($this->_mockHttpClient, $this->_mockSigner); }
private function _assignEntityToResponse($body, ehough_shortstop_api_HttpResponse $response, $debugging) { if ($debugging) { $this->getLogger()->debug('Assigning (possibly empty) entity to response'); } $entity = new ehough_shortstop_api_HttpEntity(); $entity->setContent($body); $entity->setContentLength(strlen($body)); $contentType = $response->getHeaderValue(ehough_shortstop_api_HttpResponse::HTTP_HEADER_CONTENT_TYPE); if ($contentType !== null) { $entity->setContentType($contentType); } $response->setEntity($entity); }