public function ModuleHandlerTest::testThemeMetaData in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testThemeMetaData()
Tests whether the correct theme metadata is returned.
File
- core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php, line 325
Class
- ModuleHandlerTest
- Tests ModuleHandler functionality.
Namespace
Drupal\Tests\system\Kernel\ExtensionCode
public function testThemeMetaData() {
// Generate the list of available themes.
$themes = \Drupal::service('theme_handler')
->rebuildThemeData();
// Check that the mtime field exists for the bartik theme.
$this
->assertTrue(!empty($themes['bartik']->info['mtime']), 'The bartik.info.yml file modification time field is present.');
// Use 0 if mtime isn't present, to avoid an array index notice.
$test_mtime = !empty($themes['bartik']->info['mtime']) ? $themes['bartik']->info['mtime'] : 0;
// Ensure the mtime field contains a number that is greater than zero.
$this
->assertIsNumeric($test_mtime);
$this
->assertGreaterThan(0, $test_mtime);
}