InfoParser example


  protected $infoParser;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    // Use a fake DRUPAL_ROOT.     $this->infoParser = new InfoParser('vfs:/');
  }

  /** * Tests the functionality of the infoParser object. * * @covers ::parse */
  public function testInfoParserNonExisting() {
    vfsStream::setup('modules');
    $info = $this->infoParser->parse(vfsStream::url('modules') . '/does_not_exist.info.txt');
    $this->assertEmpty($info, 'Non existing info.yml returns empty array.');
  }


  /** * Checks if the theme is a starterkit theme. * * @param \Drupal\Core\Extension\Extension $theme * The theme extension. * * @return bool */
  private function isStarterkitTheme(Extension $theme): bool {
    $info_parser = new InfoParser($this->root);
    $info = $info_parser->parse($theme->getPathname());

    return $info['starterkit'] ?? FALSE === TRUE;
  }

  /** * Gets the current Drupal major version. * * @return string */
  private function getVersion(): string {
    
return in_array($path[
        'core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml',
        'core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml',
        'core/themes/engines/twig/twig.info.yml',
      ], TRUE);
    };
    $info_parser = $this->prophesize(InfoParserInterface::class);
    $root = $this->root;
    $info_parser->parse(Argument::that($argument_condition))
      ->shouldBeCalled()
      ->will(function D$file) use ($root) {
        $info_parser = new InfoParser($root);
        return $info_parser->parse($root . '/' . $file[0]);
      });

    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $module_handler
      ->buildModuleDependencies(Argument::type('array'))
      ->willReturnArgument(0);
    $module_handler
      ->alter('system_info', Argument::type('array'), Argument::type(Extension::class), Argument::any())
      ->shouldBeCalled();

    
Home | Imprint | This part of the site doesn't use cookies.