public function PluginManagerBaseTest::testCreateInstance in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 - Contains \Drupal\Tests\Component\Plugin\PluginManagerBaseTest.
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 = array(
'config' => 'something',
);
$result = $manager
->createInstance('valid', $configuration_array);
$this
->assertEquals('valid', $result['plugin_id']);
$this
->assertArrayEquals($configuration_array, $result['configuration']);
}