本文整理汇总了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);
}
示例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'));
}
示例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);
}
示例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();
}
示例5: thenConnectionIsChecked
/**
* Verifies whether the send method is invoked once, meaning that the connection is checked.
*/
private function thenConnectionIsChecked()
{
$this->httpClient->shouldReceive('send')->once();
}