Пример #1
0
 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);
 }
 /**
  * @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'));
 }
 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
0
 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();
 }
 /**
  * Verifies whether the send method is invoked once, meaning that the connection is checked.
  */
 private function thenConnectionIsChecked()
 {
     $this->httpClient->shouldReceive('send')->once();
 }
 /**
  * Verifies whether the send method is invoked once, meaning that the connection is checked.
  */
 private function thenConnectionIsChecked()
 {
     $this->httpClient->shouldReceive('send')->once()->with(m::on(function (Request $request) {
         return $request->getMethod() == 'GET' && (string) $request->getUri() === '127.0.0.1';
     }));
 }