function ModuleHandlerTest::testThemeMetaData

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testThemeMetaData()
  2. 8.9.x core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testThemeMetaData()
  3. 10 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 352

Class

ModuleHandlerTest
Tests ModuleHandler functionality.

Namespace

Drupal\Tests\system\Kernel\Extension

Code

public function testThemeMetaData() : void {
    // Generate the list of available themes.
    $themes = \Drupal::service('extension.list.theme')->reset()
        ->getList();
    // Check that the mtime field exists for the olivero theme.
    $this->assertNotEmpty($themes['olivero']->info['mtime'], 'The olivero.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['olivero']->info['mtime']) ? $themes['olivero']->info['mtime'] : 0;
    // Ensure the mtime field contains a number that is greater than zero.
    $this->assertIsNumeric($test_mtime);
    $this->assertGreaterThan(0, $test_mtime);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.