function HelpTopicDiscoveryTest::testDiscoveryExceptionInvalidTopLevel

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

@covers ::findAll

File

core/modules/help_topics/tests/src/Unit/HelpTopicDiscoveryTest.php, line 95

Class

HelpTopicDiscoveryTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21help_topics%21src%21HelpTopicDiscovery.php/class/HelpTopicDiscovery/9" title="Discovers help topic plugins from Twig files in help_topics directories." class="local">\Drupal\help_topics\HelpTopicDiscovery</a> @group help_topics

Namespace

Drupal\Tests\help_topics\Unit

Code

public function testDiscoveryExceptionInvalidTopLevel() {
    vfsStream::setup('root');
    $topic_content = <<<EOF
---
label: 'A label'
top_level: bar
---
EOF;
    vfsStream::create([
        'modules' => [
            'test' => [
                'help_topics' => [
                    'test.topic.html.twig' => $topic_content,
                ],
            ],
        ],
    ]);
    $discovery = new HelpTopicDiscovery([
        'test' => vfsStream::url('root/modules/test/help_topics'),
    ]);
    $this->expectException(DiscoveryException::class);
    $this->expectExceptionMessage("vfs://root/modules/test/help_topics/test.topic.html.twig contains invalid value for 'top_level' key, the value must be a Boolean");
    $discovery->getDefinitions();
}

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