本文整理汇总了PHP中Guzzle\Plugin\Mock\MockPlugin::getReceivedRequests方法的典型用法代码示例。如果您正苦于以下问题:PHP MockPlugin::getReceivedRequests方法的具体用法?PHP MockPlugin::getReceivedRequests怎么用?PHP MockPlugin::getReceivedRequests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Plugin\Mock\MockPlugin
的用法示例。
在下文中一共展示了MockPlugin::getReceivedRequests方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testScales
/**
* @param string $expectedEncodedScales
* @param array $scales
*
* @dataProvider scaleDataProvider
*/
public function testScales($expectedEncodedScales, $scales)
{
$this->clientMocker->addResponse(new Response(200, null, '{"statusCode":200,"response":{"results":[]},"msecs":1}'));
$this->engineClient->find(10, array(), $scales, array());
$fields = current($this->clientMocker->getReceivedRequests())->getPostFields();
$this->assertEquals($expectedEncodedScales, $fields['scales']);
}
示例2: 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'));
}
示例3: testListTasksWithNonUtf8Response
/**
* method : listTasks
* case : search a task with a label job_label
*/
public function testListTasksWithNonUtf8Response()
{
$this->mock->addResponse(new Response(200, array('Content-Type' => 'application/json'), utf8_decode(<<<BODY
{
"result": [{
"label": "àéèjob_label"
}],
"returnCode": 0
}
BODY
)));
$return = $this->client->listTasks();
$requests = $this->mock->getReceivedRequests();
$this->assertCount(1, $requests);
$request = reset($requests);
$this->assertEquals(0, $return['returnCode']);
$this->assertEquals('http://talend.url/org.talend.administrator/metaServlet?eyJhY3Rpb25OYW1lIjoibGlzdFRhc2tzIiwiYXV0aFBhc3MiOiJwYXNzd29yZCIsImF1dGhVc2VyIjoibG9naW4iLCJtb2RlIjoic3luY2hyb25vdXMifQ=%3D', $request->getUrl());
$taskLabels = array();
if (!empty($return['result'])) {
foreach ($return['result'] as $task) {
$taskLabels[] = $task['label'];
}
}
$this->assertTrue(array_search('àéèjob_label', $taskLabels) !== false);
}
示例4: iShouldNotSeeAMessageInTheChannel
/**
* @Given /^I should not see a message in the channel$/
*/
public function iShouldNotSeeAMessageInTheChannel()
{
$requests = $this->plugin->getReceivedRequests();
if (count($requests)) {
throw new \Exception('Did not expect to see any API calls made.');
}
}
示例5: assertGuzzleRequest
/**
* @return EntityEnclosingRequestInterface
*/
protected function assertGuzzleRequest()
{
$requests = $this->guzzleMockPlugin->getReceivedRequests();
if (empty($requests)) {
throw new \PHPUnit_Framework_ExpectationFailedException("No Guzzle request to evaluate");
}
return $requests[0];
}
示例6: 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());
}
示例7: it_can_create_a_collaboration_link
/**
* @test
*/
public function it_can_create_a_collaboration_link()
{
$response = (new Response(200))->setBody(file_get_contents(__DIR__ . '/samples/LinkCreated.xml'));
$this->mockPlugin->addResponse($response);
$eventId = '004aea08-e13d-48c9-b9eb-a18f20e6d44e';
$language = new Language('en');
$subBrand = "myBrand";
$description = "description";
$plainText = "plaintext";
$rsp = $this->entryAPI->createCollaborationLink($eventId, $language, $subBrand, $description, $plainText);
$requests = $this->mockPlugin->getReceivedRequests();
/** @var RequestInterface|MessageInterface|EntityEnclosingRequestInterface $request */
$request = reset($requests);
$this->assertEquals('POST', $request->getMethod());
$this->assertEquals('http://example.com/event/004aea08-e13d-48c9-b9eb-a18f20e6d44e/links', $request->getUrl());
$this->assertEquals('application/x-www-form-urlencoded', (string) $request->getHeader('Content-Type'));
$this->assertEquals('lang=en&plaintext=plaintext&linktype=collaboration&subbrand=myBrand&description=description', (string) $request->getPostFields());
$expectedRsp = new Rsp('0.1', Rsp::LEVEL_INFO, 'LinkCreated', 'http://test.rest.uitdatabank.be/api/v3/event/004aea08-e13d-48c9-b9eb-a18f20e6d44e', '');
$this->assertEquals($expectedRsp, $rsp);
}
示例8: getRequests
/**
* @return array|Request[]
*/
protected function getRequests()
{
return $this->mock->getReceivedRequests();
}
示例9: getRequest
/**
* @param MockPlugin $plugin
*
* @return RequestInterface
*/
protected function getRequest(MockPlugin $plugin)
{
$requests = $plugin->getReceivedRequests();
return reset($requests);
}