public function NodeConditionTest::testLegacy in Drupal 9
@group legacy
File
- core/
modules/ node/ tests/ src/ Kernel/ NodeConditionTest.php, line 84
Class
- NodeConditionTest
- Tests that conditions, provided by the node module, are working properly.
Namespace
Drupal\Tests\node\KernelCode
public function testLegacy() {
$this
->expectDeprecation('Passing context values to plugins via configuration is deprecated in drupal:9.1.0 and will be removed before drupal:10.0.0. Instead, call ::setContextValue() on the plugin itself. See https://www.drupal.org/node/3120980');
$manager = $this->container
->get('plugin.manager.condition');
$article = Node::create([
'type' => 'article',
'title' => $this
->randomMachineName(),
'uid' => 1,
]);
$article
->save();
// Test Constructor injection.
$condition = $manager
->createInstance('node_type', [
'bundles' => [
'article' => 'article',
],
'context' => [
'node' => $article,
],
]);
$this
->assertTrue($condition
->execute(), 'Constructor injection of context and configuration working as anticipated.');
}