function DefaultSingleLazyPluginCollectionTest::setupPluginCollection

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

Sets up the default plugin collection.

Parameters

\PHPUnit\Framework\MockObject\Rule\InvocationOrder|null $create_count: (optional) The number of times that createInstance() is expected to be called. For example, $this->any(), $this->once(), $this->exactly(6). Defaults to $this->never().

Overrides LazyPluginCollectionTestBase::setupPluginCollection

5 calls to DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
DefaultSingleLazyPluginCollectionTest::testAddInstanceId in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::addInstanceId[[api-linebreak]] @covers ::getConfiguration[[api-linebreak]] @covers ::setConfiguration[[api-linebreak]]
DefaultSingleLazyPluginCollectionTest::testConfigurableSetConfiguration in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::setConfiguration[[api-linebreak]]
DefaultSingleLazyPluginCollectionTest::testConfigurableSetConfigurationToNull in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@covers ::setConfiguration[[api-linebreak]] @group legacy
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[[api-linebreak]]

File

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

Class

DefaultSingleLazyPluginCollectionTest
@coversDefaultClass \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection[[api-linebreak]] @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

protected function setupPluginCollection(?InvocationOrder $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.