function DefaultSingleLazyPluginCollectionTest::setupPluginCollection

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
  3. 10 core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()

Overrides LazyPluginCollectionTestBase::setupPluginCollection

4 calls to DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
DefaultSingleLazyPluginCollectionTest::testAddInstanceId in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::addInstanceId @covers ::getConfiguration @covers ::setConfiguration
DefaultSingleLazyPluginCollectionTest::testConfigurableSetConfiguration in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::setConfiguration
DefaultSingleLazyPluginCollectionTest::testGet in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
Tests the get() method.
DefaultSingleLazyPluginCollectionTest::testGetInstanceIds in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::getInstanceIds

File

core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php, line 21

Class

DefaultSingleLazyPluginCollectionTest
@coversDefaultClass \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

protected function setupPluginCollection(?InvocationOrder $create_count = NULL) : void {
    $definitions = $this->getPluginDefinitions();
    $this->pluginInstances['apple'] = new ConfigurablePlugin([
        'id' => 'apple',
        'key' => 'value',
    ], 'apple', $definitions['apple']);
    $this->pluginInstances['banana'] = new ConfigurablePlugin([
        'id' => 'banana',
        'key' => 'other_value',
    ], 'banana', $definitions['banana']);
    $create_count = $create_count ?: $this->never();
    $this->pluginManager
        ->expects($create_count)
        ->method('createInstance')
        ->willReturnCallback(function ($id) {
        return $this->pluginInstances[$id];
    });
    $this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', [
        'id' => 'apple',
        'key' => 'value',
    ]);
}

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