You are here

protected function LazyPluginCollectionTestBase::setupPluginCollection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 66
Contains \Drupal\Tests\Core\Plugin\LazyPluginCollectionTestBase.

Class

LazyPluginCollectionTestBase
Provides a base class for plugin collection tests.

Namespace

Drupal\Tests\Core\Plugin

Code

protected function setupPluginCollection(\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder $create_count = NULL) {
  $this->pluginInstances = array();
  $map = array();
  foreach ($this
    ->getPluginDefinitions() as $plugin_id => $definition) {

    // Create a mock plugin instance.
    $this->pluginInstances[$plugin_id] = $this
      ->getPluginMock($plugin_id, $definition);
    $map[] = array(
      $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(array(
    $this,
    'returnPluginMap',
  )));
  $this->defaultPluginCollection = new DefaultLazyPluginCollection($this->pluginManager, $this->config);
}