function HelpTopicDiscoveryTest::testHelpTopicsDefinition
Same name in other branches
- 8.9.x core/modules/help_topics/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help_topics\Unit\HelpTopicDiscoveryTest::testHelpTopicsDefinition()
- 10 core/modules/help/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help\Unit\HelpTopicDiscoveryTest::testHelpTopicsDefinition()
- 11.x core/modules/help/tests/src/Unit/HelpTopicDiscoveryTest.php \Drupal\Tests\help\Unit\HelpTopicDiscoveryTest::testHelpTopicsDefinition()
@covers ::findAll
File
-
core/
modules/ help_topics/ tests/ src/ Unit/ HelpTopicDiscoveryTest.php, line 226
Class
- HelpTopicDiscoveryTest
- @coversDefaultClass \Drupal\help_topics\HelpTopicDiscovery @group help_topics
Namespace
Drupal\Tests\help_topics\UnitCode
public function testHelpTopicsDefinition() {
$container = new ContainerBuilder();
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
vfsStream::setup('root');
$topic_content = <<<EOF
---
label: 'Test'
top_level: true
related:
- one
- two
- three
---
<h2>Test</h2>
EOF;
vfsStream::create([
'modules' => [
'foo' => [
'help_topics' => [
'foo.topic.html.twig' => $topic_content,
],
],
],
]);
$discovery = new HelpTopicDiscovery([
'foo' => vfsStream::url('root/modules/foo/help_topics'),
]);
$definition = $discovery->getDefinitions()['foo.topic'];
$this->assertEquals('Test', $definition['label']);
$this->assertInstanceOf(TranslatableMarkup::class, $definition['label']);
$this->assertTrue($definition['top_level']);
// Each related plugin ID should be trimmed.
$this->assertSame([
'one',
'two',
'three',
], $definition['related']);
$this->assertSame('foo', $definition['provider']);
$this->assertSame(HelpTopicTwig::class, $definition['class']);
$this->assertSame(vfsStream::url('root/modules/foo/help_topics/foo.topic.html.twig'), $definition['_discovered_file_path']);
$this->assertSame('foo.topic', $definition['id']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.