class BaseThemeMissingTest in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Theme/BaseThemeMissingTest.php \Drupal\KernelTests\Core\Theme\BaseThemeMissingTest
Tests the behavior of a theme when base_theme info key is missing.
@group Theme
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Theme\BaseThemeMissingTest
Expanded class hierarchy of BaseThemeMissingTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Theme/ BaseThemeMissingTest.php, line 17
Namespace
Drupal\KernelTests\Core\ThemeView source
class BaseThemeMissingTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
];
/**
* The theme installer.
*
* @var \Drupal\Core\Extension\ThemeInstallerInterface
*/
protected $themeInstaller;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->themeInstaller = $this->container
->get('theme_installer');
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
parent::register($container);
$container
->getDefinition('extension.list.theme')
->setClass(VfsThemeExtensionList::class);
}
/**
* {@inheritdoc}
*/
protected function setUpFilesystem() {
parent::setUpFilesystem();
$vfs_root = vfsStream::setup('core');
vfsStream::create([
'themes' => [
'test_missing_base_theme' => [
'test_missing_base_theme.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml'),
'test_missing_base_theme.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme'),
],
],
], $vfs_root);
}
/**
* Tests exception is thrown.
*/
public function testMissingBaseThemeException() {
$this->container
->get('extension.list.theme')
->setExtensionDiscovery(new ExtensionDiscovery('vfs://core'));
$this
->expectException(InfoParserException::class);
$this
->expectExceptionMessage('Missing required key ("base theme") in themes/test_missing_base_theme/test_missing_base_theme.info.yml, see https://www.drupal.org/node/3066038');
$this->themeInstaller
->install([
'test_missing_base_theme',
]);
}
}