function LazyPluginCollectionTestBase::getPluginMock

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php \Drupal\Tests\Core\Plugin\LazyPluginCollectionTestBase::getPluginMock()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php \Drupal\Tests\Core\Plugin\LazyPluginCollectionTestBase::getPluginMock()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php \Drupal\Tests\Core\Plugin\LazyPluginCollectionTestBase::getPluginMock()

Returns a mocked plugin object.

Parameters

string $plugin_id: The plugin ID.

array $definition: The plugin definition.

Return value

\Drupal\Component\Plugin\PluginInspectionInterface|\PHPUnit\Framework\MockObject\MockObject

1 call to LazyPluginCollectionTestBase::getPluginMock()
LazyPluginCollectionTestBase::setupPluginCollection in core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
Sets up the default plugin collection.
1 method overrides LazyPluginCollectionTestBase::getPluginMock()
DefaultLazyPluginCollectionTest::getPluginMock in core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
Returns a mocked plugin object.

File

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

Class

LazyPluginCollectionTestBase
Provides a base class for plugin collection tests.

Namespace

Drupal\Tests\Core\Plugin

Code

protected function getPluginMock($plugin_id, array $definition) {
    // Create a mock plugin instance.
    $mock = $this->createMock('Drupal\\Component\\Plugin\\PluginInspectionInterface');
    $mock->expects($this->any())
        ->method('getPluginId')
        ->willReturn($plugin_id);
    return $mock;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.