class ModuleInfoTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php \Drupal\Tests\Core\Extension\ModuleInfoTest
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php \Drupal\Tests\Core\Extension\ModuleInfoTest

Tests that core module info files have the expected keys.

@group Extension

Hierarchy

Expanded class hierarchy of ModuleInfoTest

File

core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php, line 14

Namespace

Drupal\Tests\Core\Extension
View source
class ModuleInfoTest extends UnitTestCase {
  use FileSystemModuleDiscoveryDataProviderTrait;
  
  /**
   * Tests that core module info files have the expected keys.
   *
   * @dataProvider coreModuleListDataProvider
   */
  public function testModuleInfo($module) {
    $module_directory = __DIR__ . '/../../../../../modules/' . $module;
    $info = Yaml::decode(file_get_contents($module_directory . '/' . $module . '.info.yml'));
    $this->assertArrayHasKey('version', $info);
    $this->assertEquals('VERSION', $info['version']);
  }

}

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