outline-8.x-1.x-dev/tests/src/Functional/ThemeTest.php
tests/src/Functional/ThemeTest.php
<?php
namespace Drupal\Tests\outline\Functional;
/**
* Verifies that various outline pages use the expected theme.
*
* @group outline
*/
class ThemeTest extends OutlineTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
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(['bartik', 'seven']);
$this->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
->save();
// Create and log in as a user who has permission to add and edit outline
// entries and view the administrative theme.
$admin_user = $this->drupalCreateUser([
'administer outline',
'view the administration theme',
]);
$this->drupalLogin($admin_user);
}
/**
* Test the theme used when adding, viewing and editing outline entries.
*/
public function testOutlineEntryThemes() {
// Adding a entry to a outline is considered an administrative action and
// should use the administrative theme.
$outline = $this->createOutline();
$this->drupalGet('admin/structure/outline/manage/' . $outline->id() . '/add');
$this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for adding a outline entry."));
// Viewing a outline entry should use the default theme.
$entry = $this->createEntry($outline);
$this->drupalGet('outline/entry/' . $entry->id());
$this->assertRaw('bartik/css/base/elements.css', t("The default theme's CSS appears on the page for viewing a outline entry."));
// Editing a outline entry should use the same theme as adding one.
$this->drupalGet('outline/entry/' . $entry->id() . '/edit');
$this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for editing a outline entry."));
}
}
