You are here

public function ApigeeEdgeManagementCliServiceTest::testDoesRoleExistServerErrorThrown in Apigee Edge 8

Validate when exception thrown function works correctly.

File

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

Class

ApigeeEdgeManagementCliServiceTest
Test ApigeeEdgeManagementCliService.

Namespace

Drupal\Tests\apigee_edge\Unit\Command\Util

Code

public function testDoesRoleExistServerErrorThrown() {

  // Http client throws exception if network or server error happens.
  $request = $this
    ->prophesize(RequestInterface::class);
  $response = $this
    ->prophesize(Response::class);
  $response
    ->getStatusCode()
    ->willReturn(500);
  $exception = new ServerException('Server error.', $request
    ->reveal(), $response
    ->reveal());
  $this
    ->expectException(ServerException::class);
  $this->httpClient
    ->get(Argument::type('string'), Argument::type('array'))
    ->willThrow($exception);
  $apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient
    ->reveal());
  $apigee_edge_management_cli_service
    ->doesRoleExist($this->org, $this->email, $this->password, $this->baseUrl, $this->roleName);
}