當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClientInterface::shouldReceive方法代碼示例

本文整理匯總了PHP中GuzzleHttp\ClientInterface::shouldReceive方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClientInterface::shouldReceive方法的具體用法?PHP ClientInterface::shouldReceive怎麽用?PHP ClientInterface::shouldReceive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GuzzleHttp\ClientInterface的用法示例。


在下文中一共展示了ClientInterface::shouldReceive方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCreatingMessageBatch

 public function testCreatingMessageBatch()
 {
     $this->guzzle->shouldReceive('createRequest')->twice()->andReturn($this->request);
     $requests = $this->client->batch(function ($pusher) {
         $pusher->send(new Message('recipient', 'text'));
         $pusher->send(new Message('recipient', 'text'));
     });
     $this->assertCount(2, $requests);
 }
開發者ID:vdbf,項目名稱:pushover-php,代碼行數:9,代碼來源:ClientTest.php

示例2: it_should_pass_no_partition_when_no_partition_available

 /**
  * @test
  * @covers ::query
  */
 public function it_should_pass_no_partition_when_no_partition_available()
 {
     $response = m::mock(Response::class);
     $this->httpClient->shouldReceive('request')->withArgs(['GET', '127.0.0.1/projection/name'])->andReturn($response);
     $result = json_encode(['data' => 'projectionData']);
     $response->shouldReceive('getStatusCode')->andReturn('200');
     $response->shouldReceive('getBody')->andReturn($result);
     $proxy = EventStoreProxy::forUrl('127.0.0.1', $this->httpClient);
     $this->assertSame(['data' => 'projectionData'], $proxy->query('name'));
 }
開發者ID:php-in-practice,項目名稱:matters-projections,代碼行數:14,代碼來源:EventStoreProxyTest.php

示例3: testErrorInResponseThrowsException

 public function testErrorInResponseThrowsException()
 {
     $text = 'Hello, World!';
     $response = m::mock(ResponseInterface::class);
     $this->guzzle->shouldReceive('request')->once()->with('GET', 'https://www.googleapis.com/language/translate/v2', ['query' => ['key' => config('translation.clients.api_key'), 'format' => 'html', 'source' => 'en', 'target' => 'es', 'q' => $text]])->andReturn($response);
     $response->shouldReceive('getBody')->andReturn(json_encode(['error' => 'foo']));
     $this->client->setSource('en');
     $this->client->setTarget('es');
     $this->setExpectedException(\ErrorException::class);
     $this->client->translate($text);
 }
開發者ID:stevebauman,項目名稱:translation,代碼行數:11,代碼來源:GoogleTranslateApiTest.php

示例4: setUp

 public function setUp()
 {
     $this->client = Mockery::mock(ClientInterface::class);
     $this->getConfigMethod = $this->client->shouldReceive('getConfig')->withArgs(['base_uri'])->once()->andReturnNull()->byDefault();
     $this->sendMethod = $this->client->shouldReceive('send')->with(\Mockery::type(Request::class))->byDefault();
 }
開發者ID:link0,項目名稱:phpebble,代碼行數:6,代碼來源:GuzzleTimelineTest.php

示例5: thenConnectionIsChecked

 /**
  * Verifies whether the send method is invoked once, meaning that the connection is checked.
  */
 private function thenConnectionIsChecked()
 {
     $this->httpClient->shouldReceive('send')->once();
 }
開發者ID:php-in-practice,項目名稱:matters-projections,代碼行數:7,代碼來源:EventStoreProjectionsDriverTest.php


注:本文中的GuzzleHttp\ClientInterface::shouldReceive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。