function DefaultPluginManagerTest::testFixContextAwareDefinitions
@covers ::fixContextAwareDefinitions
@group legacy @expectedDeprecation Providing context definitions via the "context" key is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use the "context_definitions" key instead.
File
-
core/
tests/ Drupal/ Tests/ Core/ Plugin/ DefaultPluginManagerTest.php, line 474
Class
- DefaultPluginManagerTest
- Tests the DefaultPluginManager.
Namespace
Drupal\Tests\Core\PluginCode
public function testFixContextAwareDefinitions() {
$first_definition = new ContextDefinition('first');
$second_definition = new ContextDefinition('bar');
$definitions = $this->expectedDefinitions;
$definitions['apple']['context'] = [
'incorrect' => $first_definition,
];
$definitions['apple']['context_definitions'] = [
'correct' => $second_definition,
];
$expected = $this->expectedDefinitions;
$expected['apple']['context']['correct'] = $second_definition;
$expected['apple']['context']['incorrect'] = $first_definition;
$expected['apple']['context_definitions']['correct'] = $second_definition;
$expected['apple']['context_definitions']['incorrect'] = $first_definition;
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler->reveal(), NULL);
$reflection = new \ReflectionMethod($plugin_manager, 'fixContextAwareDefinitions');
$reflection->setAccessible(TRUE);
$reflection->invokeArgs($plugin_manager, [
&$definitions,
]);
$this->assertSame($expected, $definitions);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.