You are here

public function ApigeeEdgeManagementCliServiceTest::testHandleHttpClientExceptions302Code in Apigee Edge 8

Make sure method outputs more info for error codes.

File

tests/src/Unit/Command/Util/ApigeeEdgeManagementCliServiceTest.php, line 454

Class

ApigeeEdgeManagementCliServiceTest
Test ApigeeEdgeManagementCliService.

Namespace

Drupal\Tests\apigee_edge\Unit\Command\Util

Code

public function testHandleHttpClientExceptions302Code() {

  // Return a 302 redirection response, which Apigee API would not do.
  $request = $this
    ->prophesize(RequestInterface::class);
  $response = $this
    ->prophesize(Response::class);
  $response
    ->getStatusCode()
    ->willReturn(302);
  $exception = new ClientException('Forbidden', $request
    ->reveal(), $response
    ->reveal());

  // User should see error message.
  $io = $this
    ->prophesize(StyleInterface::class);
  $io
    ->error(Argument::containingString('Error connecting to Apigee Edge'))
    ->shouldBeCalledTimes(1);
  $io
    ->note(Argument::containingString('the url ' . $this->baseUrl . '/test' . ' does not seem to be a valid Apigee Edge endpoint.'))
    ->shouldBeCalledTimes(1);
  $apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient
    ->reveal());
  $apigee_edge_management_cli_service
    ->handleHttpClientExceptions($exception, $io
    ->reveal(), [
    $this,
    'mockDt',
  ], $this->baseUrl . '/test', $this->org, $this->email);
}