You are here

protected function DefaultSingleLazyPluginCollectionTest::setupPluginCollection in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::setupPluginCollection()
  2. 9 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

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(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',
  ]);
}