You are here

public function ModuleHandlerTest::testModuleMetaData in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testModuleMetaData()
  2. 10 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testModuleMetaData()

Tests whether the correct module metadata is returned.

File

core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php, line 319

Class

ModuleHandlerTest
Tests ModuleHandler functionality.

Namespace

Drupal\Tests\system\Kernel\Extension

Code

public function testModuleMetaData() {

  // Generate the list of available modules.
  $modules = $this->container
    ->get('extension.list.module')
    ->getList();

  // Check that the mtime field exists for the system module.
  $this
    ->assertTrue(!empty($modules['system']->info['mtime']), 'The system.info.yml file modification time field is present.');

  // Use 0 if mtime isn't present, to avoid an array index notice.
  $test_mtime = !empty($modules['system']->info['mtime']) ? $modules['system']->info['mtime'] : 0;

  // Ensure the mtime field contains a number that is greater than zero.
  $this
    ->assertIsNumeric($test_mtime);
  $this
    ->assertGreaterThan(0, $test_mtime);
}