Stevebauman\Translation\Tests\GoogleTranslateApiTest::testErrorInResponseThrowsException PHP Метод

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);
    }