1 system.test InfoFileCoreTest::testProjectInfoFileContents()

Tests that the .info files of all core projects specify a project type.

File

core/modules/system/tests/system.test, line 1962
Tests for system.module.

Class

InfoFileCoreTest
Ensures that all info files have expected contents.

Code

function testProjectInfoFileContents() {
  $projects = backdrop_system_listing('/^' . BACKDROP_PHP_FUNCTION_PATTERN . '\.info$/', 'core');
  $allowed_project_types = array('module', 'theme', 'layout', 'profile');
  $type_fails = array();
  $version_fails = array();
  foreach ($projects as $key => $project) {
    $info = backdrop_parse_info_file(dirname($project->uri) . '/' . $project->name . '.info');
    if (!isset($info['type'])) {
      $type_fails[] = $key;
      $this->fail(format_string('%key does not specify a project type in the .info file.', array('%key' => $key)));
    }
    elseif (!in_array($info['type'], $allowed_project_types)) {
      $type_fails[] = $key;
      $this->fail(format_string('Invalid project type specified for %key in the .info file.', array('%key' => $key)));
    }
    if (!isset($info['version'])) {
      $version_fails[] = $key;
      $this->fail(format_string('%key does not have a version string in the .info file.', array('%key' => $key)));
    }
  }
  $this->assertFalse($type_fails, 'Proper project type set for all core projects.');
  $this->assertFalse($version_fails, 'Version set for all core projects.');
}