Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / taxonomy / tests / src / Functional / ThemeTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Functional;
4
5 /**
6  * Verifies that various taxonomy pages use the expected theme.
7  *
8  * @group taxonomy
9  */
10 class ThemeTest extends TaxonomyTestBase {
11
12   protected function setUp() {
13     parent::setUp();
14
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')
21       ->save();
22
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);
27   }
28
29   /**
30    * Test the theme used when adding, viewing and editing taxonomy terms.
31    */
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."));
38
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."));
43
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."));
47   }
48
49 }