You are here

public function ProviderBucketTest::testRoutePermissions in oEmbed Providers 2.x

Tests route permissions.

File

tests/src/Functional/ProviderBucketTest.php, line 69

Class

ProviderBucketTest
Tests the provider bucket config entity type.

Namespace

Drupal\Tests\oembed_providers\Functional

Code

public function testRoutePermissions() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalLogin($this->nonAdminUser);

  // Non-admin user is unable to access Provider Bucket listing page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets');
  $assert_session
    ->statusCodeEquals(403);

  // Non-admin user is unable to access Provider Bucket add page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/add');
  $assert_session
    ->statusCodeEquals(403);

  // Non-admin user is unable to access Provider Bucket edit page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/test_bucket/edit');
  $assert_session
    ->statusCodeEquals(403);

  // Non-admin user is unable to access Provider Bucket delete page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/test_bucket/delete');
  $assert_session
    ->statusCodeEquals(403);
  $this
    ->drupalLogin($this->adminUser);

  // Admin user is able to access Provider Bucket listing page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets');
  $assert_session
    ->statusCodeEquals(200);

  // Admin user is able to access Provider Bucket add page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/add');
  $assert_session
    ->statusCodeEquals(200);

  // Admin user is able to access Provider Bucket edit page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/test_bucket/edit');
  $assert_session
    ->statusCodeEquals(200);

  // Admin user is able to access Provider Bucket delete page.
  $this
    ->drupalGet('/admin/config/media/oembed-providers/buckets/test_bucket/delete');
  $assert_session
    ->statusCodeEquals(200);
}