Verified Commit 3586d9b3 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2513524 by andregp, JeroenT, Bill Choy, TR, tstoeckler, dawehner, Wim...

Issue #2513524 by andregp, JeroenT, Bill Choy, TR, tstoeckler, dawehner, Wim Leers, xjm: ExtensionDiscovery is unable to find modules that have a comment at the end of the type property in a .info.yml file

(cherry picked from commit 1066bfe2)
parent f5aced44
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -444,7 +444,7 @@ protected function scanDirectory($dir, $include_tests) {
        $type = FALSE;
        $file = $fileinfo->openFile('r');
        while (!$type && !$file->eof()) {
          preg_match('@^type:\s*(\'|")?(\w+)\1?\s*$@', $file->fgets(), $matches);
          preg_match('@^type:\s*(\'|")?(\w+)\1?\s*(?:\#.*)?$@', $file->fgets(), $matches);
          if (isset($matches[2])) {
            $type = $matches[2];
          }
+5 −0
Original line number Diff line number Diff line
name: 'Module info type comment test'
type: module # Test that extension discovery works with a trailing comment for the type element.
description: 'Support module for module system testing.'
package: Testing
version: VERSION
+11 −0
Original line number Diff line number Diff line
@@ -98,6 +98,17 @@ public function testExtensionDiscoveryCache() {
    ], $file_cache->get($this->root . '/core/modules/user/user.info.yml'));
  }

  /**
   * Tests finding modules that have a trailing comment on the type property.
   *
   * @covers ::scan
   */
  public function testExtensionDiscoveryTypeComment(): void {
    $extension_discovery = new ExtensionDiscovery($this->root, TRUE, [], 'sites/default');
    $modules = $extension_discovery->scan('module', TRUE);
    $this->assertArrayHasKey('module_info_type_comment', $modules);
  }

  /**
   * Adds example files to the filesystem structure.
   *