class ThemeHandlerTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php \Drupal\Tests\Core\Extension\ThemeHandlerTest
- 10 core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php \Drupal\Tests\Core\Extension\ThemeHandlerTest
- 9 core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php \Drupal\Tests\Core\Extension\ThemeHandlerTest
- 8.9.x core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php \Drupal\Tests\Core\Extension\ThemeHandlerTest
Tests Drupal\Core\Extension\ThemeHandler.
Attributes
#[CoversClass(ThemeHandler::class)]
#[Group('Extension')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Extension\ThemeHandlerTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of ThemeHandlerTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ ThemeHandlerTest.php, line 18
Namespace
Drupal\Tests\Core\ExtensionView source
class ThemeHandlerTest extends UnitTestCase {
/**
* The mocked config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $configFactory;
/**
* The theme listing service.
*
* @var \Drupal\Core\Extension\ThemeExtensionList|\PHPUnit\Framework\MockObject\MockObject
*/
protected $themeList;
/**
* The tested theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandler|\Drupal\Tests\Core\Extension\StubThemeHandler
*/
protected $themeHandler;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->configFactory = $this->getConfigFactoryStub([
'core.extension' => [
'module' => [],
'theme' => [
'stark' => 'stark',
],
'disabled' => [
'theme' => [],
],
],
]);
$this->themeList = $this->getMockBuilder(ThemeExtensionList::class)
->disableOriginalConstructor()
->getMock();
$this->themeHandler = new StubThemeHandler($this->root, $this->configFactory, $this->themeList);
$container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$container->expects($this->any())
->method('get')
->with('class_loader')
->willReturn($this->createMock(ClassLoader::class));
\Drupal::setContainer($container);
}
/**
* Tests empty libraries in theme.info.yml file.
*/
public function testThemeLibrariesEmpty() : void {
$theme = new Extension($this->root, 'theme', 'core/modules/system/tests/themes/test_theme_libraries_empty', 'test_theme_libraries_empty.info.yml');
try {
$this->themeHandler
->addTheme($theme);
$this->assertTrue(TRUE, 'Empty libraries key in theme.info.yml does not cause PHP warning');
} catch (\Exception) {
$this->fail('Empty libraries key in theme.info.yml causes PHP warning.');
}
}
/**
* Test that a missing theme doesn't break ThemeHandler::listInfo().
*
* @legacy-covers ::listInfo
*/
public function testMissingTheme() : void {
$themes = $this->themeHandler
->listInfo();
$this->assertSame([], $themes);
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|---|
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 | ||
| ExpectDeprecationTrait::expectDeprecation | Deprecated | public | function | Adds an expected deprecation. | ||
| ExpectDeprecationTrait::regularExpressionForFormatDescription | private | function | ||||
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |||
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |||
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |||
| ThemeHandlerTest::$configFactory | protected | property | The mocked config factory. | |||
| ThemeHandlerTest::$themeHandler | protected | property | The tested theme handler. | |||
| ThemeHandlerTest::$themeList | protected | property | The theme listing service. | |||
| ThemeHandlerTest::setUp | protected | function | Overrides UnitTestCase::setUp | |||
| ThemeHandlerTest::testMissingTheme | public | function | Test that a missing theme doesn't break ThemeHandler::listInfo(). | |||
| ThemeHandlerTest::testThemeLibrariesEmpty | public | function | Tests empty libraries in theme.info.yml file. | |||
| UnitTestCase::$root | protected | property | The app root. | |||
| UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |||
| UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |||
| UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |||
| UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |||
| UnitTestCase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |||
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.