function ContextDefinitionTest::testIsSatisfiedBy
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\ContextDefinitionTest::testIsSatisfiedBy()
- 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\ContextDefinitionTest::testIsSatisfiedBy()
- 10 core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\ContextDefinitionTest::testIsSatisfiedBy()
@covers ::isSatisfiedBy
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ ContextDefinitionTest.php, line 28
Class
- ContextDefinitionTest
- @coversDefaultClass \Drupal\Core\Plugin\Context\ContextDefinition @group Plugin
Namespace
Drupal\KernelTests\Core\PluginCode
public function testIsSatisfiedBy() : void {
$this->installEntitySchema('user');
$value = EntityTest::create([]);
// Assert that the entity has at least one violation.
$this->assertNotEmpty($value->validate());
// Assert that these violations do not prevent it from satisfying the
// requirements of another object.
$requirement = new ContextDefinition('any');
$context = EntityContext::fromEntity($value);
$this->assertTrue($requirement->isSatisfiedBy($context));
// Test with multiple values.
$definition = EntityContextDefinition::create('entity_test');
$definition->setMultiple();
$entities = [
EntityTest::create([]),
EntityTest::create([]),
];
$context = new Context($definition, $entities);
$this->assertTrue($definition->isSatisfiedBy($context));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.