public function ApigeeEdgeManagementCliServiceTest::testHandleHttpClientExceptions401Code in Apigee Edge 8
Make sure method outputs more info for error codes.
File
- tests/
src/ Unit/ Command/ Util/ ApigeeEdgeManagementCliServiceTest.php, line 416
Class
- ApigeeEdgeManagementCliServiceTest
- Test ApigeeEdgeManagementCliService.
Namespace
Drupal\Tests\apigee_edge\Unit\Command\UtilCode
public function testHandleHttpClientExceptions401Code() {
// Server returns 401 unauthorized.
$request = $this
->prophesize(RequestInterface::class);
$response = $this
->prophesize(Response::class);
$response
->getStatusCode()
->willReturn(401);
$exception = new ClientException('Unauthorized', $request
->reveal(), $response
->reveal());
// Expect user friendly message displayed about error.
$io = $this
->prophesize(StyleInterface::class);
$io
->error(Argument::containingString('Error connecting to Apigee Edge'))
->shouldBeCalledTimes(1);
$io
->note(Argument::exact('Your username or password is invalid.'))
->shouldBeCalledTimes(1);
$apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient
->reveal());
$apigee_edge_management_cli_service
->handleHttpClientExceptions($exception, $io
->reveal(), [
$this,
'mockDt',
], 'http://api.apigee.com/test', $this->org, $this->email);
}