本文整理汇总了PHP中GuzzleHttp\Message\Response::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::expects方法的具体用法?PHP Response::expects怎么用?PHP Response::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\Response
的用法示例。
在下文中一共展示了Response::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleErrorShouldRaiseExceptionWhenHostIsFromPagSeguro
/**
* @test
* @expectedException \PHPSC\PagSeguro\Client\PagSeguroException
*/
public function handleErrorShouldRaiseExceptionWhenHostIsFromPagSeguro()
{
$client = new Client($this->httpClient);
$transaction = new Transaction($this->httpClient, $this->request);
$transaction->response = $this->response;
$event = new Event($transaction);
$this->request->expects($this->any())->method('getHost')->willReturn(Production::WS_HOST);
$this->response->expects($this->any())->method('getStatusCode')->willReturn(401);
$this->response->expects($this->any())->method('getBody')->willReturn('Unauthorized');
$client->handleError($event);
}
示例2: testRequestExceptionWithResponseThrowsDropletException
/**
* Test to ensure that a RequestException with a response throws a droplet exception
*
* @expectedException \Billow\Exceptions\DropletException
*/
public function testRequestExceptionWithResponseThrowsDropletException()
{
$page = 1;
$per_page = 5;
$headers = ['Content-type' => 'application/json'];
$this->mockResponse->expects($this->once())->method('getBody')->will($this->returnValue('Unauthorized Request'));
$this->mockResponse->expects($this->once())->method('getStatusCode')->will($this->returnValue(401));
$this->mockException->expects($this->once())->method('hasResponse')->will($this->returnValue(true));
$this->mockException->expects($this->once())->method('getResponse')->will($this->returnValue($this->mockResponse));
$this->mockClient->expects($this->once())->method('get')->with("droplets?page={$page}&per_page={$per_page}", ['headers' => $headers])->will($this->throwException($this->mockException));
$service = new DropletService();
$service->setClient($this->mockClient);
$droplets = $service->retrieveAll($headers, $per_page, $page);
}
示例3: testEnsureMessageCanBeSent
/**
* Test to ensure message is able to be sent correctly
*/
public function testEnsureMessageCanBeSent()
{
// Set up the data fixture
$fh = fopen('tests/Mocking/API/Fixtures/send-data.txt', 'r');
$response = fread($fh, 4096);
fclose($fh);
$channel = 'C04C8KJRC';
$text = 'This is a test';
$url = self::BASEURL . 'chat.postMessage';
$bodyParam = ['body' => ['token' => $this->token, 'channel' => $channel, 'text' => $text]];
$this->client->expects($this->once())->method('post')->with($url, $bodyParam)->will($this->returnValue($this->response));
$this->response->expects($this->once())->method('getBody')->will($this->returnValue($response));
$slack = new Slack($this->client, $this->token);
$result = $slack->sendMessage($text, $channel);
$arrayResponse = json_decode($result, true);
$this->assertTrue($arrayResponse['ok']);
$this->assertEquals($arrayResponse['channel'], $channel);
$this->assertEquals($arrayResponse['message']['text'], $text);
}