function PluginManagerBaseTest::getMockFactoryInterface

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::getMockFactoryInterface()
  2. 10 core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::getMockFactoryInterface()
  3. 11.x core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::getMockFactoryInterface()

Generates a mocked FactoryInterface object with known properties.

2 calls to PluginManagerBaseTest::getMockFactoryInterface()
PluginManagerBaseTest::testCreateInstance in core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
Tests createInstance() with no fallback methods.
PluginManagerBaseTest::testCreateInstanceFallback in core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
Tests createInstance() with a fallback method.

File

core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php, line 35

Class

PluginManagerBaseTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Plugin%21PluginManagerBase.php/class/PluginManagerBase/8.9.x" title="Base class for plugin managers." class="local">\Drupal\Component\Plugin\PluginManagerBase</a> @group Plugin

Namespace

Drupal\Tests\Component\Plugin

Code

public function getMockFactoryInterface($expects_count) {
    $mock_factory = $this->getMockBuilder('Drupal\\Component\\Plugin\\Factory\\FactoryInterface')
        ->setMethods([
        'createInstance',
    ])
        ->getMockForAbstractClass();
    $mock_factory->expects($this->exactly($expects_count))
        ->method('createInstance')
        ->willReturnCallback([
        $this,
        'createInstanceCallback',
    ]);
    return $mock_factory;
}

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