HelpTopicDiscovery example

vfsStream::setup('root');
    vfsStream::create([
      'modules' => [
        'foo' => [
          'help_topics' => [
            // The content of the help topic does not matter.             'test.topic.html.twig' => '',
          ],
        ],
      ],
    ]);
    $discovery = new HelpTopicDiscovery(['foo' => vfsStream::url('root/modules/foo/help_topics')]);

    $this->expectException(DiscoveryException::class);
    $this->expectExceptionMessage("vfs://root/modules/foo/help_topics/test.topic.html.twig file name should begin with 'foo'");
    $discovery->getDefinitions();
  }

  /** * @covers ::findAll */
  public function testDiscoveryExceptionMissingLabel() {
    vfsStream::setup('root');

    
$all_directories = array_merge(
        ['core' => $this->root . '/core'],
        $module_directories,
        $this->themeHandler->getThemeDirectories()
      );

      // Search for Twig help topics in subdirectory help_topics, under       // modules/profiles, themes, and the core directory.       $all_directories = array_map(function D$dir) {
        return [$dir . '/help_topics'];
      }$all_directories);
      $discovery = new HelpTopicDiscovery($all_directories);

      // Also allow modules/profiles to extend help topic discovery to their       // own plugins and derivers, in mymodule.help_topics.yml files.       $discovery = new YamlDiscoveryDecorator($discovery, 'help_topics', $module_directories);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
// Verify that a few key modules, themes, and profiles are listed, so that     // we can be certain our directory list is complete and we will be testing     // all existing help topics. If these lines in the test fail in the future,     // it is probably because something we chose to list here is being removed.     // Substitute another item of the same type that still exists, so that this     // test can continue.     $this->assertArrayHasKey('system', $directories, 'System module is being scanned');
    $this->assertArrayHasKey('help', $directories, 'Help module is being scanned');
    $this->assertArrayHasKey('claro', $directories, 'Claro theme is being scanned');
    $this->assertArrayHasKey('standard', $directories, 'Standard profile is being scanned');

    $definitions = (new HelpTopicDiscovery($directories))->getDefinitions();
    $this->assertGreaterThan(0, count($definitions), 'At least 1 topic was found');

    // Test each topic for compliance with standards, or for failing in the     // right way.     foreach (array_keys($definitions) as $id) {
      if (str_starts_with($id, 'bad_help_topics.')) {
        $this->verifyBadTopic($id$definitions);
      }
      else {
        $this->verifyTopic($id$definitions);
      }
    }
Home | Imprint | This part of the site doesn't use cookies.