当前位置: 首页>>代码示例>>PHP>>正文


PHP Google_Client::setIo方法代码示例

本文整理汇总了PHP中Google_Client::setIo方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::setIo方法的具体用法?PHP Google_Client::setIo怎么用?PHP Google_Client::setIo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google_Client的用法示例。


在下文中一共展示了Google_Client::setIo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupTestClient

 /**
  * Setup the Google Cient with our 'monitored' HTTP IO
  *
  * @return \Google_Client
  */
 private function setupTestClient()
 {
     $obj_client = new \Google_Client();
     $this->obj_fake_io = new Google_IO_Fake($obj_client);
     $obj_client->setIo($this->obj_fake_io);
     return $obj_client;
 }
开发者ID:gonejack,项目名称:tumblr-images-datastore,代码行数:12,代码来源:JSONTest.php

示例2: testTokenAcquisition

 public function testTokenAcquisition()
 {
     $client = new Google_Client();
     /* Mock out refresh call */
     $response_data = json_encode(array('access_token' => "ACCESS_TOKEN", 'expires_in' => "12345"));
     $response = $this->getMock("Google_Http_Request", array(), array(''));
     $response->expects($this->any())->method('getResponseHttpCode')->will($this->returnValue(200));
     $response->expects($this->any())->method('getResponseBody')->will($this->returnValue($response_data));
     $io = $this->getMock("Google_IO_Stream", array(), array($client));
     $client->setIo($io);
     $io->expects($this->any())->method('makeRequest')->will($this->returnCallback(function ($request) use($response) {
         return $response;
     }));
     /* Run method */
     $oauth = new Google_Auth_ComputeEngine($client);
     $oauth->acquireAccessToken();
     $token = json_decode($oauth->getAccessToken(), true);
     /* Check results */
     $this->assertEquals($token['access_token'], "ACCESS_TOKEN");
     $this->assertEquals($token['expires_in'], "12345");
     $this->assertTrue($token['created'] > 0);
 }
开发者ID:imonroe,项目名称:coldreader,代码行数:22,代码来源:ComputeEngineAuthTest.php

示例3: testRefreshTokenSetsValues

 /**
  * Test that the ID token is properly refreshed.
  */
 public function testRefreshTokenSetsValues()
 {
     $client = new Google_Client();
     $response_data = json_encode(array('access_token' => "ACCESS_TOKEN", 'id_token' => "ID_TOKEN", 'expires_in' => "12345"));
     $response = $this->getMock("Google_Http_Request", array(), array(''));
     $response->expects($this->any())->method('getResponseHttpCode')->will($this->returnValue(200));
     $response->expects($this->any())->method('getResponseBody')->will($this->returnValue($response_data));
     $io = $this->getMock("Google_IO_Stream", array(), array($client));
     $io->expects($this->any())->method('makeRequest')->will($this->returnCallback(function ($request) use(&$token, $response) {
         $elements = $request->getPostBody();
         PHPUnit_Framework_TestCase::assertEquals($elements['grant_type'], "refresh_token");
         PHPUnit_Framework_TestCase::assertEquals($elements['refresh_token'], "REFRESH_TOKEN");
         return $response;
     }));
     $client->setIo($io);
     $oauth = new Google_Auth_OAuth2($client);
     $oauth->refreshToken("REFRESH_TOKEN");
     $token = json_decode($oauth->getAccessToken(), true);
     $this->assertEquals($token['id_token'], "ID_TOKEN");
 }
开发者ID:SaintGrey,项目名称:sheets2,代码行数:23,代码来源:ApiOAuth2Test.php


注:本文中的Google_Client::setIo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。