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


PHP MockPlugin::addResponse方法代码示例

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


在下文中一共展示了MockPlugin::addResponse方法的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: slackRespondsOk

 /**
  * @Given /^Slack will respond ok to all requests$/
  */
 public function slackRespondsOk()
 {
     $this->plugin->addResponse($this->getSuccessResponse());
     $this->plugin->getEventDispatcher()->addListener('mock.request', function () {
         $this->plugin->addResponse($this->getSuccessResponse());
     });
 }
开发者ID:orukusaki,项目名称:slackbundle,代码行数:10,代码来源:SlackContext.php

示例3: testExceptionThrownWhenBatchErrors

 /**
  * @expectedException Fabricius\Exception\RuntimeException
  * @expectedExceptionMessage Request to Github failed: An error occured [500]
  */
 public function testExceptionThrownWhenBatchErrors()
 {
     $this->plugin->addResponse(new Response(200, null, json_encode(array(array('path' => 'mock')))));
     $this->plugin->addResponse(new Response(500, null, json_encode(array('message' => 'An error occured'))));
     $parser = Phake::mock('Fabricius\\Parser\\ParserInterface');
     $provider = new GithubLoader($this->client, 'GITHUB OWNER', 'GITHUB REPO');
     $metadata = Phake::mock('Fabricius\\Metadata\\ClassMetadata');
     $content = $provider->load($metadata, $parser);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:13,代码来源:GithubLoaderTest.php

示例4: testGetTokenFromJwt

 public function testGetTokenFromJwt()
 {
     $xml = file_get_contents(__DIR__ . '/samples/token-without-consumer.xml');
     $response = new Response('200', null, $xml);
     $this->apiMock->addResponse($response);
     $token = $this->fetcher->getAccessTokenFromJwt('0005548e3bfe0a47938fd5b1c8369ff1');
     $correctToken = new Token('2143f7db7642b3687e90d718b79a42ce', '4c06eb61aa814a057578640ee61ea420', new User('12346093-0e7e-4803-be0b-69b24c145f89', 'testtesttest', 'testtestest@cultuurnet.be'));
     $this->assertEquals($correctToken, $token);
 }
开发者ID:cultuurnet,项目名称:uitid-credentials,代码行数:9,代码来源:UitidCredentialsFetcherTest.php

示例5: testGetRequestToken

 public function testGetRequestToken()
 {
     $callbackUrl = 'http://www.example.com/twitter/callback';
     $this->factoryMock->expects($this->once())->method('getOAuthConnection')->with()->will($this->returnValue($this->bootstrapClient()));
     $this->mockPlugin->addResponse(__DIR__ . '/fixtures/request_token.txt');
     $requestToken = $this->bootstrapGateway()->getRequestToken($callbackUrl);
     $this->assertEquals('foo', $requestToken['oauth_token']);
     $this->assertEquals('bar', $requestToken['oauth_token_secret']);
     $receivedRequests = $this->mockPlugin->getReceivedRequests();
     $this->assertCount(1, $receivedRequests);
     $this->assertEquals($callbackUrl, $receivedRequests[0]->getHeader('oauth_callback'));
 }
开发者ID:derrabus,项目名称:twitter-signin-bundle,代码行数:12,代码来源:TwitterApiGatewayTest.php

示例6: prepareClient

 /**
  * @param MockPlugin $plugin
  * @param $code
  * @param null $body
  *
  * @return MyrrixClient
  */
 protected function prepareClient(MockPlugin $plugin, $code, $body = null)
 {
     $client = MyrrixClient::factory();
     $plugin->addResponse(new Response($code, null, $body));
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:ulkas,项目名称:bcc-myrrix,代码行数:14,代码来源:MyrrixClientTest.php

示例7: 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

示例8: 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

示例9: 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

示例10: setUp

 protected function setUp()
 {
     $this->mock = new MockPlugin();
     $this->mock->addResponse(new Response(200));
     $this->client = new Client();
     $this->client->addSubscriber($this->mock);
 }
开发者ID:ataxel,项目名称:tp,代码行数:7,代码来源:VarnishTest.php

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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