function PluginManagerBaseTest::testCreateInstance
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testCreateInstance()
- 10 core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testCreateInstance()
- 11.x core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testCreateInstance()
Tests createInstance() with no fallback methods.
@covers ::createInstance
File
-
core/
tests/ Drupal/ Tests/ Component/ Plugin/ PluginManagerBaseTest.php, line 53
Class
- PluginManagerBaseTest
- @coversDefaultClass \Drupal\Component\Plugin\PluginManagerBase @group Plugin
Namespace
Drupal\Tests\Component\PluginCode
public function testCreateInstance() {
$manager = $this->getMockBuilder('Drupal\\Component\\Plugin\\PluginManagerBase')
->getMockForAbstractClass();
// PluginManagerBase::createInstance() looks for a factory object and then
// calls createInstance() on it. So we have to mock a factory object.
$factory_ref = new \ReflectionProperty($manager, 'factory');
$factory_ref->setAccessible(TRUE);
$factory_ref->setValue($manager, $this->getMockFactoryInterface(1));
// Finally the test.
$configuration_array = [
'config' => 'something',
];
$result = $manager->createInstance('valid', $configuration_array);
$this->assertEquals('valid', $result['plugin_id']);
$this->assertEquals($configuration_array, $result['configuration']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.