本文整理汇总了PHP中Github\Client::setHttpClient方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setHttpClient方法的具体用法?PHP Client::setHttpClient怎么用?PHP Client::setHttpClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Github\Client
的用法示例。
在下文中一共展示了Client::setHttpClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMockBadReleaseslApi
protected function getMockBadReleaseslApi($method = 'post')
{
$httpClientMock = $this->getMock('Guzzle\\Http\\Client', array('send'));
$httpClientMock->expects($this->any())->method('send');
$mock = $this->getMock('Github\\HttpClient\\HttpClient', array(), array(array(), $httpClientMock));
$client = new Github\Client($mock);
$client->setHttpClient($mock);
// Mock the Issue API.
$repoMock = $this->getMockBuilder('Github\\Api\\Repo')->setMethods(array('releases'))->setConstructorArgs(array($client))->getMock();
// Mock the label API.
$releasesMock = $this->getMockBuilder('Github\\Api\\Repository\\Releases')->setMethods(array('all', 'show', 'showTag', 'create', 'edit', 'remove', 'assets'))->setConstructorArgs(array($client))->getMock();
$releasesMock->method('showTag')->will($this->throwException(new \Exception()));
// This actually runs an assert and makes sure our API call actually returns that :-O.
$repoMock->method($method)->will($this->returnValue('Success'));
// Set up the Issue API to return the Label api.
$repoMock->expects($this->exactly(1))->method('releases')->willReturn($releasesMock);
return $repoMock;
}
示例2: getGithubClient
/**
* Return or generate github client on-demand
*
* @param OutputInterface $output
* @return GithubClient
*/
protected function getGithubClient(OutputInterface $output)
{
if ($this->githubClient) {
return $this->githubClient;
}
// Create authenticated github client
$token = $this->getOAUTHToken($output);
$client = new GithubClient();
$httpClient = GuzzleClient::createWithConfig(['http_errors' => false]);
$client->setHttpClient($httpClient);
$client->authenticate($token, null, GithubClient::AUTH_HTTP_TOKEN);
// Cache
$this->githubClient = $client;
return $client;
}
示例3: getClientMock
protected function getClientMock(HttpClientInterface $httpClient = null)
{
// if no httpClient isset use the default HttpClient mock
if (!$httpClient) {
$httpClient = $this->getHttpClientMock();
}
$client = new \Github\Client($httpClient);
$client->setHttpClient($httpClient);
return $client;
}