You are here

protected function LazyPluginCollectionTestBase::setupPluginCollection in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php \Drupal\Tests\Core\Plugin\LazyPluginCollectionTestBase::setupPluginCollection()

Sets up the default plugin collection.

Parameters

\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder|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().

13 calls to LazyPluginCollectionTestBase::setupPluginCollection()
DefaultLazyPluginCollectionTest::testAddInstanceId in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@covers ::addInstanceId
DefaultLazyPluginCollectionTest::testClear in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@covers ::clear
DefaultLazyPluginCollectionTest::testConfigurableGetConfiguration in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@covers ::getConfiguration
DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@covers ::setConfiguration
DefaultLazyPluginCollectionTest::testCount in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@covers ::count

... See full list

1 method overrides LazyPluginCollectionTestBase::setupPluginCollection()
DefaultSingleLazyPluginCollectionTest::setupPluginCollection in core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
Sets up the default plugin collection.

File

core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php, line 62

Class

LazyPluginCollectionTestBase
Provides a base class for plugin collection tests.

Namespace

Drupal\Tests\Core\Plugin

Code

protected function setupPluginCollection(InvokedRecorder $create_count = NULL) {
  $this->pluginInstances = [];
  $map = [];
  foreach ($this
    ->getPluginDefinitions() as $plugin_id => $definition) {

    // Create a mock plugin instance.
    $this->pluginInstances[$plugin_id] = $this
      ->getPluginMock($plugin_id, $definition);
    $map[] = [
      $plugin_id,
      $this->config[$plugin_id],
      $this->pluginInstances[$plugin_id],
    ];
  }
  $create_count = $create_count ?: $this
    ->never();
  $this->pluginManager
    ->expects($create_count)
    ->method('createInstance')
    ->will($this
    ->returnCallback([
    $this,
    'returnPluginMap',
  ]));
  $this->defaultPluginCollection = new DefaultLazyPluginCollection($this->pluginManager, $this->config);
}