You are here

public function ApiDocsAccessTest::testApiDocAccessAdmin in Apigee API Catalog 8

Test admin access control functionality for apidocs.

File

tests/src/Functional/ApiDocsAccessTest.php, line 100

Class

ApiDocsAccessTest
Tests the ApiDoc term access permissions.

Namespace

Drupal\Tests\apigee_api_catalog\Functional

Code

public function testApiDocAccessAdmin() {
  $assert_session = $this
    ->assertSession();

  // Test the 'administer apigee api catalog' permission.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer apigee api catalog',
    'administer apidoc display',
    'administer apidoc fields',
    'administer apidoc form display',
  ]));
  $this
    ->drupalGet($this->apidocPublished
    ->toUrl());
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocPublished, 'view', TRUE);
  $this
    ->drupalGet($this->apidocUnpublished
    ->toUrl());
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocUnpublished, 'view', TRUE);
  $this
    ->drupalGet($this->apidocPublished
    ->toUrl('edit-form'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocPublished, 'update', TRUE);
  $this
    ->drupalGet($this->apidocUnpublished
    ->toUrl('edit-form'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocUnpublished, 'update', TRUE);
  $this
    ->drupalGet($this->apidocPublished
    ->toUrl('delete-form'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocPublished, 'delete', TRUE);
  $this
    ->drupalGet($this->apidocUnpublished
    ->toUrl('delete-form'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->assertApiDocAccess($this->apidocUnpublished, 'delete', TRUE);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.collection'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.add_form'));
  $assert_session
    ->statusCodeEquals(200);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.settings'));
  $assert_session
    ->statusCodeEquals(200);

  // Make sure the field manipulation links are available.
  $assert_session
    ->linkExists('Settings');
  $assert_session
    ->linkExists('Manage fields');
  $assert_session
    ->linkExists('Manage form display');
  $assert_session
    ->linkExists('Manage display');
}