You are here

public function ApigeeEdgeManagementCliServiceTest::testDoesRoleExist in Apigee Edge 8

Test Edge API response/request for doesRoleExist()

File

tests/src/Kernel/Util/ApigeeEdgeManagementCliServiceTest.php, line 185

Class

ApigeeEdgeManagementCliServiceTest
ApigeeEdgeManagementCliService Edge tests.

Namespace

Drupal\Tests\apigee_edge\Kernel\Util

Code

public function testDoesRoleExist() {

  // Role should not exist.
  $url = $this->endpoint . '/o/' . $this->organization . '/userroles/' . self::TEST_ROLE_NAME;
  $errorMsg = 'Userrole temp_role does not exist';
  $this->stack
    ->queueMockResponse([
    'get_not_found' => [
      'status_code' => 404,
      'message' => $errorMsg,
    ],
  ]);
  $this
    ->expectException(ClientErrorException::class);
  $this
    ->expectExceptionMessage($errorMsg);
  $response = $this->httpClient
    ->get($url);
  $this
    ->assertEquals('404', $response
    ->getStatusCode(), 'Role that does not exist should return 404.');
}