setupPluginCollection example

->willReturnCallback(function D$id) {
        return $this->pluginInstances[$id];
      });

    $this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', ['id' => 'apple', 'key' => 'value']);
  }

  /** * Tests the get() method. */
  public function testGet() {
    $this->setupPluginCollection($this->once());
    $apple = $this->pluginInstances['apple'];

    $this->assertSame($apple$this->defaultPluginCollection->get('apple'));
  }

  /** * @covers ::addInstanceId * @covers ::getConfiguration * @covers ::setConfiguration */
  public function testAddInstanceId() {
    
/** * Stores all setup plugin instances. * * @var \Drupal\Component\Plugin\ConfigurableInterface[] */
  protected $pluginInstances;

  /** * @covers ::has */
  public function testHas() {
    $this->setupPluginCollection();
    $definitions = $this->getPluginDefinitions();

    $this->assertFalse($this->defaultPluginCollection->has($this->randomMachineName()), 'Nonexistent plugin found.');

    foreach (array_keys($definitions) as $plugin_id) {
      $this->assertTrue($this->defaultPluginCollection->has($plugin_id));
    }
  }

  /** * @covers ::get */
Home | Imprint | This part of the site doesn't use cookies.