class ThemeTest
Same name in this branch
- 9 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest
- 9 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest
- 9 core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest
- 11.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest
- 11.x core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest
- 11.x core/modules/taxonomy/tests/src/Functional/ThemeTest.php \Drupal\Tests\taxonomy\Functional\ThemeTest
- 10 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest
- 10 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest
- 10 core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest
- 10 core/modules/taxonomy/tests/src/Functional/ThemeTest.php \Drupal\Tests\taxonomy\Functional\ThemeTest
- 8.9.x core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest
- 8.9.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest
- 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeTest.php \Drupal\Tests\system\Functional\Theme\ThemeTest
- 8.9.x core/modules/taxonomy/tests/src/Functional/ThemeTest.php \Drupal\Tests\taxonomy\Functional\ThemeTest
Verifies that various taxonomy pages use the expected theme.
@group taxonomy
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\taxonomy\Functional\TaxonomyTestBase uses \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait, \Drupal\Tests\field\Traits\EntityReferenceTestTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\taxonomy\Functional\ThemeTest extends \Drupal\Tests\taxonomy\Functional\TaxonomyTestBase
- class \Drupal\Tests\taxonomy\Functional\TaxonomyTestBase uses \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait, \Drupal\Tests\field\Traits\EntityReferenceTestTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ThemeTest
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ ThemeTest.php, line 10
Namespace
Drupal\Tests\taxonomy\FunctionalView source
class ThemeTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Make sure we are using distinct default and administrative themes for
// the duration of these tests.
\Drupal::service('theme_installer')->install([
'olivero',
'claro',
]);
$this->config('system.theme')
->set('default', 'olivero')
->set('admin', 'claro')
->save();
// 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([
'administer taxonomy',
'view the administration theme',
]);
$this->drupalLogin($admin_user);
}
/**
* Tests the theme used when adding, viewing and editing taxonomy terms.
*/
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('claro/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('olivero/css/base/base.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('claro/css/base/elements.css');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.