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


PHP Response::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:leonardorifeli,项目名称:pagseguro,代码行数:15,代码来源:ClientTest.php

示例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);
 }
开发者ID:mfrost503,项目名称:billow,代码行数:19,代码来源:DropletServiceTest.php

示例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);
 }
开发者ID:WenkeZhou,项目名称:phpunit-tutorial,代码行数:22,代码来源:SlackTest.php


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