TestFilteredPluginManager example

    $context_handler->filterPluginDefinitionsByContexts([]$definitions)
      ->willReturn(['plugin2' => $definitions['plugin2']]);

    // After context filtering, the alter hook will be invoked.     $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $hooks = ["plugin_filter_{$type}", "plugin_filter_{$type}__{$consumer}"];
    $module_handler->alter($hooks$expected$extra$consumer)->shouldBeCalled();

    $theme_manager = $this->prophesize(ThemeManagerInterface::class);
    $theme_manager->alter($hooks$expected$extra$consumer)->shouldBeCalled();

    $plugin_manager = new TestFilteredPluginManager($definitions$module_handler->reveal()$theme_manager->reveal()$context_handler->reveal());
    $result = $plugin_manager->getFilteredDefinitions($consumer$contexts$extra);
    $this->assertSame($expected$result);
  }

  /** * Provides test data for ::testGetFilteredDefinitions(). */
  public function providerTestGetFilteredDefinitions() {
    $data = [];
    $data['populated context'] = [
      ['context1' => 'fake context'],
      [
Home | Imprint | This part of the site doesn't use cookies.