function HelpTopicsSyntaxTest::register

Same name and namespace in other branches
  1. main core/modules/help/tests/src/Kernel/HelpTopicsSyntaxTest.php \Drupal\Tests\help\Kernel\HelpTopicsSyntaxTest::register()

Registers test-specific services.

Extend this method in your test to register additional services. This method is called whenever the kernel is rebuilt.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The service container to enhance.

Overrides KernelTestBase::register

File

core/modules/help/tests/src/Kernel/HelpTopicsSyntaxTest.php, line 69

Class

HelpTopicsSyntaxTest
Verifies that all core Help topics can be rendered and comply with standards.

Namespace

Drupal\Tests\help\Kernel

Code

public function register(ContainerBuilder $container) : void {
  parent::register($container);
  // Add a twig extension that registers this test class as a node visitor.
  $extension = new class ($this) extends AbstractExtension {
    public function __construct(protected readonly NodeVisitorInterface $nodeVisitor) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function getNodeVisitors() : array {
      return [
        $this->nodeVisitor,
      ];
    }

};
  $definition = new Definition(get_class($extension));
  $definition->addTag('twig.extension', [
    'priority' => 500,
  ]);
  $definition->addArgument($this);
  $container->setDefinition('help_test_twig.extension', $definition);
}

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