You are here

AccessThemeBrowserTest.php in Theme permission 8

Same filename and directory in other branches
  1. 2.0.x tests/src/Functional/AccessThemeBrowserTest.php

File

tests/src/Functional/AccessThemeBrowserTest.php
View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\theme_permission\Functional;

use Drupal\Core\Url;

/**
 * Administration theme access check.
 *
 * @group theme_permission
 */
class AccessThemeBrowserTest extends ThemePermissionTestBase {

  /**
   * Check if user access to Bartik theme.
   */
  public function testIfAccessThemeBartik() {
    $this
      ->userLogin([
      'administer themes bartik',
    ]);
    $this
      ->drupalGet(Url::fromRoute('system.theme_settings_theme', [
      'theme' => 'bartik',
    ]));
    $this
      ->assertSession()
      ->statusCodeEquals(200);
  }

  /**
   * Check if user don't access to Bartik theme.
   */
  public function testIfAccessDeniedThemeBartik() {
    $this
      ->userLogin();
    $this
      ->drupalGet(Url::fromRoute('system.theme_settings_theme', [
      'theme' => 'bartik',
    ]));
    $this
      ->assertSession()
      ->statusCodeEquals(403);
  }

  /**
   * Check if the user accesses "Edit Administration theme".
   */
  public function testEditAdminTheme() {
    $this
      ->userLogin([
      'Edit Administration theme',
    ]);
    $this
      ->drupalGet(Url::fromRoute('system.themes_page'));
    $this
      ->assertSession()
      ->pageTextContains('Choose "Default theme" to always use the same theme as the rest of the site.');
  }

  /**
   * Check if the user not accesses "Edit Administration theme".
   */
  public function testNotEditAdminTheme() {
    $this
      ->userLogin();
    $this
      ->drupalGet(Url::fromRoute('system.themes_page'));
    $this
      ->assertSession()
      ->pageTextNotContains('Choose "Default theme" to always use the same theme as the rest of the site.');
  }

  /**
   * Check if permission is present in permissions page.
   */
  public function testIfPermissionsIsPresent() {
    $this
      ->userLogin([
      'administer permissions',
    ]);
    $this
      ->drupalGet('/admin/people/permissions');
    $this
      ->assertSession()
      ->pageTextContains('administer themes bartik');
    $this
      ->assertSession()
      ->pageTextContains('uninstall themes bartik');
    $this
      ->assertSession()
      ->pageTextContains('Edit Administration theme');
  }

}

Classes

Namesort descending Description
AccessThemeBrowserTest Administration theme access check.