ThemeTest.php 1.86 KB
Newer Older
1 2 3 4 5
<?php

namespace Drupal\taxonomy\Tests;

/**
6 7 8
 * Verifies that various taxonomy pages use the expected theme.
 *
 * @group taxonomy
9 10 11
 */
class ThemeTest extends TaxonomyTestBase {

12
  protected function setUp() {
13 14 15 16
    parent::setUp();

    // Make sure we are using distinct default and administrative themes for
    // the duration of these tests.
17
    \Drupal::service('theme_handler')->install(array('bartik', 'seven'));
18
    $this->config('system.theme')
19
      ->set('default', 'bartik')
20
      ->set('admin', 'seven')
21
      ->save();
22 23 24 25 26 27 28 29 30 31 32 33 34 35

    // Create and log in as a user who has permission to add and edit taxonomy
    // terms and view the administrative theme.
    $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme'));
    $this->drupalLogin($admin_user);
  }

  /**
   * Test the theme used when adding, viewing and editing taxonomy terms.
   */
  function testTaxonomyTermThemes() {
    // Adding a term to a vocabulary is considered an administrative action and
    // should use the administrative theme.
    $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 40

    // Viewing a taxonomy term should use the default theme.
    $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
}