• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mock\MockPlugin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Guzzle\Plugin\Mock\MockPlugin的典型用法代码示例。如果您正苦于以下问题:PHP MockPlugin类的具体用法?PHP MockPlugin怎么用?PHP MockPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testThatAssumeRoleWithWebIdentityRequestsDoNotGetSigned

 public function testThatAssumeRoleWithWebIdentityRequestsDoNotGetSigned()
 {
     $client = StsClient::factory();
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200));
     $client->addSubscriber($mock);
     $command = $client->getCommand('AssumeRoleWithWebIdentity', array('RoleArn' => 'xxxxxxxxxxxxxxxxxxxxxx', 'RoleSessionName' => 'xx', 'WebIdentityToken' => 'xxxx'));
     $request = $command->prepare();
     $command->execute();
     $this->assertFalse($request->hasHeader('Authorization'));
 }
开发者ID:njbhatt18,项目名称:Amazon_API,代码行数:11,代码来源:StsClientTest.php


示例2: testCreateServiceRequest

 /**
  * @param array $input
  * @param bool $expectSuccess
  *
  * @covers GeoPal\Open311\Clients\TorontoClient::createServiceRequest
  * @dataProvider providerTestCreateServiceRequest
  */
 public function testCreateServiceRequest($input, $expectSuccess)
 {
     $stubResponse = array(array(ServiceRequest::FIELD_SERVICE_REQUEST_ID => 'stub_id'));
     /**
      * Create and set up fake guzzle client
      */
     $response = is_null($stubResponse) ? new Response(200) : new Response(200, null, json_encode($stubResponse));
     $mockPlugin = new MockPlugin();
     $mockPlugin->addResponse($response);
     $stubGuzzleClient = new Client();
     $stubGuzzleClient->addSubscriber($mockPlugin);
     /**
      * Create test client
      */
     $client = new TorontoClient('testing', $stubGuzzleClient);
     /**
      * Check call result
      */
     if ($expectSuccess) {
         $this->assertInstanceOf('\\GeoPal\\Open311\\ServiceRequestResponse', $client->createServiceRequest($input[ServiceRequest::FIELD_SERVICE_CODE], $input[ServiceRequest::FIELD_LATITUDE], $input[ServiceRequest::FIELD_LONGITUDE], $input[ServiceRequest::FIELD_ADDRESS_STRING], $input[ServiceRequest::FIELD_ADDRESS_ID], $input[ServiceRequest::FIELD_EMAIL], $input[ServiceRequest::FIELD_DEVICE_ID], $input[ServiceRequest::FIELD_ACCOUNT_ID], $input[ServiceRequest::FIELD_FIRST_NAME], $input[ServiceRequest::FIELD_LAST_NAME], $input[ServiceRequest::FIELD_PHONE], $input[ServiceRequest::FIELD_DESCRIPTION], $input[ServiceRequest::FIELD_MEDIA_URL]));
     } else {
         $result = false;
         $exceptionThrown = false;
         try {
             // Throw an exception or change $result from false to null
             $result = $client->createServiceRequest($input[ServiceRequest::FIELD_SERVICE_CODE], $input[ServiceRequest::FIELD_LATITUDE], $input[ServiceRequest::FIELD_LONGITUDE], $input[ServiceRequest::FIELD_ADDRESS_STRING], $input[ServiceRequest::FIELD_EMAIL], $input[ServiceRequest::FIELD_DEVICE_ID], $input[ServiceRequest::FIELD_ACCOUNT_ID], $input[ServiceRequest::FIELD_FIRST_NAME], $input[ServiceRequest::FIELD_LAST_NAME], $input[ServiceRequest::FIELD_PHONE], $input[ServiceRequest::FIELD_DESCRIPTION], $input[ServiceRequest::FIELD_MEDIA_URL]);
         } catch (Open311Exception $e) {
             $exceptionThrown = true;
         }
         $this->assertTrue($exceptionThrown || is_null($result));
     }
 }
开发者ID:geopal-solutions,项目名称:open311-client,代码行数:39,代码来源:TorontoClientTest.php


示例3: testGetQueue

 public function testGetQueue()
 {
     $client = new Client();
     $mock = new MockPlugin();
     $mock->addResponse(__DIR__ . '/fixtures/get-queue');
     $client->addGuzzlePlugin($mock);
     $response = $client->getQueue('/', 'testqueue');
     $this->assertInstanceOf(Queue::class, $response);
     $this->assertEquals(17568, $response->getMemory());
     $this->assertEquals('', $response->getConsumerUtilisation());
     $this->assertEquals(new \DateTime('2014-11-21 00:48:25'), $response->getIdleSince());
     $this->assertEquals('HA', $response->getPolicy());
     $this->assertEquals(4, $response->getConsumerCount());
     $this->assertEquals('', $response->getExclusiveConsumerTag());
     $this->assertEquals(['rabbit@cookie', 'rabbit@cupcake'], $response->getSlaveNodes());
     $this->assertEquals(['rabbit@cupcake', 'rabbit@cookie'], $response->getSynchronizedSlaveNodes());
     $this->assertEquals('running', $response->getState());
     $this->assertCount(4, $response->getConsumers());
     foreach ($response->getConsumers() as $consumer) {
         $this->verifyConsumer($consumer);
     }
     $this->assertEquals('datawarehouse_update_sku_saleability', $response->getQueueName());
     $this->assertEquals('/', $response->getQueueVhost());
     $this->assertEquals(true, $response->isDurable());
     $this->assertEquals(false, $response->isAutoDeleted());
     $this->assertEquals([], $response->getArguments());
     $this->assertEquals('rabbit@scone', $response->getNode());
     $this->assertEquals(1293437, $response->getAckCount());
 }
开发者ID:hautelook,项目名称:rabbitmq-api,代码行数:29,代码来源:ClientTest.php


示例4: testDeletesArchive

 public function testDeletesArchive()
 {
     // Arrange
     $mock = new MockPlugin();
     $response = MockPlugin::getMockFile(self::$mockBasePath . 'v2/partner/APIKEY/archive/ARCHIVEID/delete');
     $mock->addResponse($response);
     $this->client->addSubscriber($mock);
     // Act
     // TODO: should this test be run on an archive object whose fixture has status 'available'
     // instead of 'started'?
     $success = $this->archive->delete();
     // Assert
     $requests = $mock->getReceivedRequests();
     $this->assertCount(1, $requests);
     $request = $requests[0];
     $this->assertEquals('DELETE', strtoupper($request->getMethod()));
     $this->assertEquals('/v2/partner/' . $this->API_KEY . '/archive/' . $this->archiveData['id'], $request->getPath());
     $this->assertEquals('api.opentok.com', $request->getHost());
     $this->assertEquals('https', $request->getScheme());
     $contentType = $request->getHeader('Content-Type');
     $this->assertNotEmpty($contentType);
     $this->assertEquals('application/json', $contentType);
     $authString = $request->getHeader('X-TB-PARTNER-AUTH');
     $this->assertNotEmpty($authString);
     $this->assertEquals($this->API_KEY . ':' . $this->API_SECRET, $authString);
     // TODO: test the dynamically built User Agent string
     $userAgent = $request->getHeader('User-Agent');
     $this->assertNotEmpty($userAgent);
     $this->assertStringStartsWith('OpenTok-PHP-SDK/2.3.2-alpha.1', $userAgent->__toString());
     $this->assertTrue($success);
     // TODO: assert that all properties of the archive object were cleared
 }
开发者ID:maniraju,项目名称:OpenTok-PHP-SDK,代码行数:32,代码来源:ArchiveTest.php


示例5: newHttpClient

 public function newHttpClient()
 {
     $client = parent::newHttpClient();
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200));
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:muditdugar,项目名称:php-project-starter,代码行数:8,代码来源:DummyJenkinsJob.php


示例6: getMockGuzzle3Client

 private function getMockGuzzle3Client($statusCode = 200, $content = null)
 {
     $plugin = new MockPlugin();
     $plugin->addResponse(new Guzzle3Response($statusCode, null, $content));
     $client = new Guzzle3Client();
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:peterfudge,项目名称:api,代码行数:8,代码来源:GuzzleHttpServiceTest.php


示例7: getMockClient

 private function getMockClient($statusCode = 200, $content = null)
 {
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response($statusCode, null, $content));
     $client = new Client(null, array('request.options' => array('exceptions' => false)));
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:riteshkmr33,项目名称:ovessnce,代码行数:8,代码来源:GuzzleHttpServiceTest.php


示例8: addResponse

 public function addResponse($code, $body, $headers = null)
 {
     $plugin = new MockPlugin();
     $response = new Response($code, $headers, $body);
     $plugin->addResponse($response);
     $this->plugin = $plugin;
     $this->getClient()->addSubscriber($plugin);
 }
开发者ID:dustler,项目名称:hipchat,代码行数:8,代码来源:ClientForTest.php


示例9: testHandlerThrowsErrorWhenClassNotExists

 /**
  * @expectedException Fabricius\Exception\RuntimeException
  */
 public function testHandlerThrowsErrorWhenClassNotExists()
 {
     $plugin = new MockPlugin();
     $plugin->addResponse(__DIR__ . '/md_github_400_response.txt');
     $this->client->addSubscriber($plugin);
     $handler = new MarkdownGithubHandler($this->client);
     $formatted = $handler->format("#Hello World");
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:11,代码来源:MarkdownGithubHandlerTest.php


示例10: testSendsRequests

 /**
  * @dataProvider requestProvider
  */
 public function testSendsRequests($method)
 {
     $mock = new MockPlugin(array(new Response(200)));
     call_user_func('Guzzle\\Http\\StaticClient::' . $method, 'http://foo.com', array('plugins' => array($mock)));
     $requests = $mock->getReceivedRequests();
     $this->assertCount(1, $requests);
     $this->assertEquals($method, $requests[0]->getMethod());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:11,代码来源:StaticClientTest.php


示例11: testGetCampaignSuppressionImports

 public function testGetCampaignSuppressionImports()
 {
     $client = new AdvertiserClient();
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200));
     $client->addSubscriber($plugin);
     $client->setAdvertiser(2, 'thekey', 'thesecret');
     $client->getCampaignSuppressionImports(1);
 }
开发者ID:emailbidding,项目名称:advertiser-client-php,代码行数:9,代码来源:AdvertiserClientTest.php


示例12: getMockClient

 protected function getMockClient(Response $response = null)
 {
     $response = $response ?: new Response(200);
     $plugin = new MockPlugin();
     $plugin->addResponse($response);
     $client = new Client();
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:9,代码来源:MessageValidatorTest.php


示例13: let

 function let()
 {
     $client = new Client();
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200, ['Content-Type' => 'text/xml'], file_get_contents(__DIR__ . '/station-facilities.xml')));
     $client->addSubscriber($plugin);
     $this->beConstructedWith('http://example/station-facilities.xml');
     $this->setClient($client);
 }
开发者ID:mramsden,项目名称:tefel,代码行数:9,代码来源:StationsFeedSpec.php


示例14: setUp

 /**
  *
  */
 protected function setUp()
 {
     parent::setUp();
     $guzzleClient = new GuzzleClient('http://www.test.com/');
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200, array(), 'test'));
     $guzzleClient->addSubscriber($mock);
     $this->geopalClient = new GeoPalClient(null, null, $guzzleClient);
 }
开发者ID:tymiles003,项目名称:geopal-php-client,代码行数:12,代码来源:ClientTest.php


示例15: createConfiguration

 private function createConfiguration($response)
 {
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200, null, $response));
     $client = new GuzzleClient();
     $client->addSubscriber($plugin);
     $this->ringCaptcha = new RingCaptcha($this->apiKey, $this->appKey);
     $this->ringCaptcha->setClient($client);
 }
开发者ID:tripda,项目名称:ring-captcha,代码行数:9,代码来源:RingCaptchaTest.php


示例16: setUp

 /**
  * Setup
  */
 public function setUp()
 {
     $plugin = new MockPlugin();
     $response = new GuzzleResponse(200);
     $response->setBody(file_get_contents(__DIR__ . '/Fixtures/response_projects.json'));
     $plugin->addResponse($response);
     $client = new VersionEyeClient('foo');
     $client->addSubscriber($plugin);
     $this->object = new VersionEyeApi($client, 'foo');
 }
开发者ID:digitalkaoz,项目名称:VersionEyeBundle,代码行数:13,代码来源:VersionEyeApiTest.php


示例17: testReponse

 public function testReponse()
 {
     // example for mock Responses
     $client = OmDataClient::factory(array('api_key' => '****'));
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200, null, 'This is the body content'));
     $client->addSubscriber($plugin);
     $command = $client->getCommand('serps_weekly/get_rankings', array('keyword' => 'hausbau', 'date' => '2013-11-24'));
     $result = $command->execute();
     //var_dump($result->getBody(true));
 }
开发者ID:LukasGrebe,项目名称:online-marketing-api-toolkit,代码行数:11,代码来源:ResponseTest.php


示例18: testThatAssumeRoleWithWebIdentityRequestsDoNotGetSigned

 public function testThatAssumeRoleWithWebIdentityRequestsDoNotGetSigned()
 {
     $client = CognitoIdentityClient::factory(array('region' => 'us-east-1'));
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200));
     $client->addSubscriber($mock);
     $command = $client->getCommand('GetId', array('AccountId' => '1234567890', 'IdentityPoolId' => 'abc:abc'));
     $request = $command->prepare();
     $command->execute();
     $this->assertFalse($request->hasHeader('Authorization'));
 }
开发者ID:njbhatt18,项目名称:Amazon_API,代码行数:11,代码来源:CognitoIdentityClientTest.php


示例19: buildClient

 public function buildClient($code, $headers, $body)
 {
     $response = new Response($code, $headers, $body);
     $client = new HTTPClient('https://api.sendgrid.com');
     $mock = new MockPlugin();
     $mock->addResponse($response);
     $client->addSubscriber($mock);
     $sendgrid = new Client('sendgrid_apikey');
     $sendgrid->setClient($client);
     return $sendgrid;
 }
开发者ID:esportspools,项目名称:sendgrid-php,代码行数:11,代码来源:baseTest.php


示例20: testXYZ

 public function testXYZ()
 {
     $client = new Client();
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200, null, json_encode(array("access_token" => "my_access_token", "token_type" => "BeArEr", "refresh_token" => "why_not_a_refresh_token"))));
     $client->addSubscriber($mock);
     $state = new State(array("state" => "my_state", "client_config_id" => "foo", "issue_time" => time() - 100, "user_id" => "my_user_id", "scope" => Scope::fromString("foo bar")));
     $this->storage->storeState($state);
     $callback = new Callback("foo", $this->clientConfig[0], $this->storage, $client);
     $tokenResponse = $callback->handleCallback(array("state" => "my_state", "code" => "my_code"));
     $this->assertEquals("my_access_token", $tokenResponse->getAccessToken());
 }
开发者ID:Farik2605,项目名称:tobi,代码行数:12,代码来源:CallbackTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Service\Client类代码示例发布时间:2022-05-23
下一篇:
PHP Parser\ParserRegistry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap