public function ContextDefinitionTest::testConstraints in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest::testConstraints()
- 10 core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest::testConstraints()
Tests adding constraints via annotations.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Annotation/ ContextDefinitionTest.php, line 22
Class
- ContextDefinitionTest
- @coversDefaultClass \Drupal\Core\Annotation\ContextDefinition @group Plugin
Namespace
Drupal\KernelTests\Core\Plugin\AnnotationCode
public function testConstraints() {
$definition = $this->container
->get('plugin.manager.block')
->getDefinition('test_context_aware');
$this
->assertArrayHasKey('context_definitions', $definition);
$this
->assertArrayHasKey('user', $definition['context_definitions']);
$this
->assertInstanceOf(ContextDefinition::class, $definition['context_definitions']['user']);
$this
->assertEquals([
'NotNull' => [],
], $definition['context_definitions']['user']
->getConstraints());
$this
->assertEquals("User Context", $definition['context_definitions']['user']
->getLabel());
}