function HelpTopicDiscoveryTest::testHelpTopicsBrokenYaml

Same name and namespace in other branches
  1. 9 core/modules/help_topics/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help_topics\Unit\HelpTopicDiscoveryTest::testHelpTopicsBrokenYaml()
  2. 8.9.x core/modules/help_topics/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help_topics\Unit\HelpTopicDiscoveryTest::testHelpTopicsBrokenYaml()
  3. 11.x core/modules/help/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help\Unit\HelpTopicDiscoveryTest::testHelpTopicsBrokenYaml()

@covers ::findAll

File

core/modules/help/tests/src/Unit/HelpTopicDiscoveryTest.php, line 179

Class

HelpTopicDiscoveryTest
@coversDefaultClass \Drupal\help\HelpTopicDiscovery[[api-linebreak]] @group help

Namespace

Drupal\Tests\help\Unit

Code

public function testHelpTopicsBrokenYaml() : void {
  vfsStream::setup('root');
  $topic_content = <<<EOF
---
foo : [bar}
---
<h2>Test</h2>
EOF;
  vfsStream::create([
    'modules' => [
      'help' => [
        'help_topics' => [
          'core.topic.html.twig' => $topic_content,
        ],
      ],
    ],
  ]);
  $discovery = new HelpTopicDiscovery([
    'help' => vfsStream::url('root/modules/help/help_topics'),
  ]);
  $this->expectException(DiscoveryException::class);
  $this->expectExceptionMessage("Malformed YAML in help topic \"vfs://root/modules/help/help_topics/core.topic.html.twig\":");
  $discovery->getDefinitions();
}

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