SearchPluginCollection example


  protected $pluginInstances;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->pluginManager = $this->createMock('Drupal\Component\Plugin\PluginManagerInterface');
    $this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', ['id' => 'banana', 'color' => 'yellow'], 'fruit_stand');
  }

  /** * Tests the get() method. */
  public function testGet() {
    $plugin = $this->createMock('Drupal\search\Plugin\SearchInterface');
    $this->pluginManager->expects($this->once())
      ->method('createInstance')
      ->willReturn($plugin);
    $this->assertSame($plugin$this->searchPluginCollection->get('banana'));
  }
return $this->getPluginCollection()->get($this->plugin);
  }

  /** * Encapsulates the creation of the search page's LazyPluginCollection. * * @return \Drupal\Component\Plugin\LazyPluginCollection * The search page's plugin collection. */
  protected function getPluginCollection() {
    if (!$this->pluginCollection) {
      $this->pluginCollection = new SearchPluginCollection($this->searchPluginManager()$this->plugin, $this->configuration, $this->id());
    }
    return $this->pluginCollection;
  }

  /** * {@inheritdoc} */
  public function getPluginCollections() {
    return ['configuration' => $this->getPluginCollection()];
  }

  
Home | Imprint | This part of the site doesn't use cookies.