You are here

public function ApigeeEdgeManagementCliServiceTest::testDoesRoleExistNotTrue in Apigee Edge 8

Validate doesRoleExist works when role exists.

File

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

Class

ApigeeEdgeManagementCliServiceTest
Test ApigeeEdgeManagementCliService.

Namespace

Drupal\Tests\apigee_edge\Unit\Command\Util

Code

public function testDoesRoleExistNotTrue() {

  // The role should not exist in system.
  $request_role = $this
    ->prophesize(RequestInterface::class);
  $response_role = $this
    ->prophesize(Response::class);
  $response_role
    ->getStatusCode()
    ->willReturn(404);
  $exception = new ClientException('Forbidden', $request_role
    ->reveal(), $response_role
    ->reveal());
  $this->httpClient
    ->get(Argument::exact($this->baseUrl . '/o/' . $this->org . '/userroles/' . $this->roleName), Argument::type('array'))
    ->willThrow($exception);
  $apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient
    ->reveal());
  $does_role_exist = $apigee_edge_management_cli_service
    ->doesRoleExist($this->org, $this->email, $this->password, $this->baseUrl, $this->roleName);

  // Assert returns false.
  $this
    ->assertEquals(FALSE, $does_role_exist, 'Method doesRoleExist() should return false when role exists.');
}