/**
* {@inheritdoc}
*/
protected static $modules =
['node', 'user'
];
/**
* Tests that DefaultFactory can create a plugin instance.
*/
public function testDefaultFactory() { // Ensure a non-derivative plugin can be instantiated.
$plugin =
$this->testPluginManager->
createInstance('user_login',
['title' => 'Please enter your login name and password'
]);
$this->
assertSame('Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockUserLoginBlock',
get_class($plugin), 'Correct plugin class instantiated with default factory.'
);
$this->
assertSame('Please enter your login name and password',
$plugin->
getTitle(), 'Plugin instance correctly configured.'
);
// Ensure that attempting to instantiate non-existing plugins throws a
// PluginException.
try { $this->testPluginManager->
createInstance('non_existing'
);
$this->
fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected'
);
} catch (\Exception
$e) { $this->
assertInstanceOf(ExceptionInterface::
class,
$e);
}