You are here

public function ThemeTest::testTaxonomyTermThemes in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Functional/ThemeTest.php \Drupal\Tests\taxonomy\Functional\ThemeTest::testTaxonomyTermThemes()

Tests the theme used when adding, viewing and editing taxonomy terms.

File

core/modules/taxonomy/tests/src/Functional/ThemeTest.php, line 40

Class

ThemeTest
Verifies that various taxonomy pages use the expected theme.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testTaxonomyTermThemes() {

  // Adding a term to a vocabulary is considered an administrative action and
  // should use the administrative theme.
  $vocabulary = $this
    ->createVocabulary();
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary
    ->id() . '/add');

  // Check that the administrative theme's CSS appears on the page for adding
  // a taxonomy term.
  $this
    ->assertSession()
    ->responseContains('seven/css/base/elements.css');

  // Viewing a taxonomy term should use the default theme.
  $term = $this
    ->createTerm($vocabulary);
  $this
    ->drupalGet('taxonomy/term/' . $term
    ->id());

  // Check that the default theme's CSS appears on the page for viewing
  // a taxonomy term.
  $this
    ->assertSession()
    ->responseContains('bartik/css/base/elements.css');

  // Editing a taxonomy term should use the same theme as adding one.
  $this
    ->drupalGet('taxonomy/term/' . $term
    ->id() . '/edit');

  // Check that the administrative theme's CSS appears on the page for editing
  // a taxonomy term.
  $this
    ->assertSession()
    ->responseContains('seven/css/base/elements.css');
}