|
@@ 28-46 (lines=19) @@
|
| 25 |
|
$this->assertInstanceOf('GuzzleHttp\Client', $client->getValue($translator)); |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function testAccountQuotaExceeded() |
| 29 |
|
{ |
| 30 |
|
$client = new Client(); |
| 31 |
|
|
| 32 |
|
$mock = new Mock([ |
| 33 |
|
new Response(200, [], Stream::factory('{"access_token":"valid"}')), |
| 34 |
|
new Response(400, [], Stream::factory($this->quotaExceededResponse)) |
| 35 |
|
]); |
| 36 |
|
|
| 37 |
|
$client->getEmitter()->attach($mock); |
| 38 |
|
|
| 39 |
|
$this->setExpectedException( |
| 40 |
|
'\badams\MicrosoftTranslator\Exceptions\QuotaExceededException', |
| 41 |
|
strip_tags($this->quotaExceededResponse) |
| 42 |
|
); |
| 43 |
|
|
| 44 |
|
$translator = new MicrosoftTranslator($client); |
| 45 |
|
$translator->translate('Hello', 'en', 'de'); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public function testArgumentException() |
| 49 |
|
{ |
|
@@ 48-66 (lines=19) @@
|
| 45 |
|
$translator->translate('Hello', 'en', 'de'); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public function testArgumentException() |
| 49 |
|
{ |
| 50 |
|
$client = new Client(); |
| 51 |
|
|
| 52 |
|
$mock = new Mock([ |
| 53 |
|
new Response(200, [], Stream::factory('{"access_token":"valid"}')), |
| 54 |
|
new Response(400, [], Stream::factory($this->argumentExceptionResponse)) |
| 55 |
|
]); |
| 56 |
|
|
| 57 |
|
$client->getEmitter()->attach($mock); |
| 58 |
|
|
| 59 |
|
$this->setExpectedException( |
| 60 |
|
'\badams\MicrosoftTranslator\Exceptions\ArgumentException', |
| 61 |
|
strip_tags($this->argumentExceptionResponse) |
| 62 |
|
); |
| 63 |
|
|
| 64 |
|
$translator = new MicrosoftTranslator($client); |
| 65 |
|
$translator->translate('Hello', 'en', 'de'); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
public function testExpiredToken() |
| 69 |
|
{ |