ModuleInfoTest.php

Same filename and directory in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php
  3. 9 core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php

Namespace

Drupal\Tests\Core\Extension

File

core/tests/Drupal/Tests/Core/Extension/ModuleInfoTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Core\Extension;

use Drupal\Component\Serialization\Yaml;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;

/**
 * Tests that core module info files have the expected keys.
 */
class ModuleInfoTest extends UnitTestCase {
  use FileSystemModuleDiscoveryDataProviderTrait;
  
  /**
   * Tests that core module info files have the expected keys.
   */
  public function testModuleInfo($module) : void {
    $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']);
  }

}

Classes

Title Deprecated Summary
ModuleInfoTest Tests that core module info files have the expected keys.

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