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. 10 core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()

Overrides LazyPluginCollectionTestBase::setupPluginCollection

3 calls to DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
DefaultSingleLazyPluginCollectionTest::testAddInstanceId in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::addInstanceId @covers ::getConfiguration @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 19

Class

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

Namespace

Drupal\Tests\Core\Plugin

Code

protected function setupPluginCollection(InvokedRecorder $create_count = NULL) {
    $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.