You are here

public function ApiDocsAccessTest::testApiDocAccessEdit in Apigee API Catalog 8

Test edit permission for apidocs.

File

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

Class

ApiDocsAccessTest
Tests the ApiDoc term access permissions.

Namespace

Drupal\Tests\apigee_api_catalog\Functional

Code

public function testApiDocAccessEdit() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'edit apidoc entities',
  ]));
  $this
    ->drupalGet($this->apidocPublished
    ->toUrl());
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->assertApiDocAccess($this->apidocPublished, 'view', FALSE);
  $this
    ->drupalGet($this->apidocUnpublished
    ->toUrl());
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->assertApiDocAccess($this->apidocUnpublished, 'view', FALSE);
  $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(403);
  $this
    ->assertApiDocAccess($this->apidocPublished, 'delete', FALSE);
  $this
    ->drupalGet($this->apidocUnpublished
    ->toUrl('delete-form'));
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->assertApiDocAccess($this->apidocUnpublished, 'delete', FALSE);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.collection'));
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.add_form'));
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->drupalGet(Url::fromRoute('entity.apidoc.settings'));
  $assert_session
    ->statusCodeEquals(403);
}