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


PHP Mock\MockPlugin类代码示例

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


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


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