class ThemeUpdateTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php \Drupal\Tests\system\Functional\Theme\ThemeUpdateTest
- 10 core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php \Drupal\Tests\system\Functional\Theme\ThemeUpdateTest
Tests low-level theme functions.
@group Theme
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 implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Theme\ThemeUpdateTest uses \Drupal\Tests\UpdatePathTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ThemeUpdateTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeUpdateTest.php, line 13
Namespace
Drupal\Tests\system\Functional\ThemeView source
class ThemeUpdateTest extends BrowserTestBase {
use UpdatePathTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'starterkit_theme';
/**
* Ensures preprocess functions run even for suggestion implementations.
*
* The theme hook used by this test has its base preprocess function in a
* separate file, so this test also ensures that the file is correctly loaded
* when needed.
*/
public function testThemeUpdates() {
\Drupal::service('module_installer')->install([
'test_module_required_by_theme',
]);
$this->rebuildAll();
\Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', [
'dependencies' => [
'test_module_required_by_theme',
'stark',
],
]);
\Drupal::service('theme_installer')->install([
'test_theme_depending_on_modules',
]);
$this->assertTrue(\Drupal::service('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme installed');
\Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', FALSE);
\Drupal::state()->set('test_theme_depending_on_modules.post_update', TRUE);
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('test_another_module_required_by_theme'));
$this->runUpdates();
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('test_another_module_required_by_theme'));
$this->assertSession()
->addressEquals('update.php/results');
$this->assertSession()
->responseContains('test_theme_depending_on_modules theme');
$this->assertSession()
->responseContains('Post update message from theme post update function');
}
/**
* {@inheritdoc}
*/
protected function doSelectionTest() {
// Ensure that the theme's post update appears as expected.
$this->assertSession()
->responseContains('test_theme_depending_on_modules theme');
$this->assertSession()
->responseContains('Install a dependent module.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.