function PluginManagerBaseTest::testCreateInstance
Tests createInstance() with no fallback methods.
@legacy-covers ::createInstance
File
-
core/
tests/ Drupal/ Tests/ Component/ Plugin/ PluginManagerBaseTest.php, line 56
Class
Namespace
Drupal\Tests\Component\PluginCode
public function testCreateInstance() : void {
$manager = new StubPluginManagerBase();
// 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->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.