3 namespace Drupal\Tests\taxonomy\Functional;
6 * Verifies that various taxonomy pages use the expected theme.
10 class ThemeTest extends TaxonomyTestBase {
12 protected function setUp() {
15 // Make sure we are using distinct default and administrative themes for
16 // the duration of these tests.
17 \Drupal::service('theme_handler')->install(['bartik', 'seven']);
18 $this->config('system.theme')
19 ->set('default', 'bartik')
20 ->set('admin', 'seven')
23 // Create and log in as a user who has permission to add and edit taxonomy
24 // terms and view the administrative theme.
25 $admin_user = $this->drupalCreateUser(['administer taxonomy', 'view the administration theme']);
26 $this->drupalLogin($admin_user);
30 * Test the theme used when adding, viewing and editing taxonomy terms.
32 public function testTaxonomyTermThemes() {
33 // Adding a term to a vocabulary is considered an administrative action and
34 // should use the administrative theme.
35 $vocabulary = $this->createVocabulary();
36 $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
37 $this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for adding a taxonomy term."));
39 // Viewing a taxonomy term should use the default theme.
40 $term = $this->createTerm($vocabulary);
41 $this->drupalGet('taxonomy/term/' . $term->id());
42 $this->assertRaw('bartik/css/base/elements.css', t("The default theme's CSS appears on the page for viewing a taxonomy term."));
44 // Editing a taxonomy term should use the same theme as adding one.
45 $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
46 $this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for editing a taxonomy term."));