3 namespace Drupal\KernelTests\Core\Plugin;
5 use Drupal\Core\Plugin\Context\ContextDefinition;
6 use Drupal\Core\Plugin\Context\EntityContext;
7 use Drupal\entity_test\Entity\EntityTest;
8 use Drupal\KernelTests\KernelTestBase;
11 * @coversDefaultClass \Drupal\Core\Plugin\Context\ContextDefinition
14 class ContextDefinitionTest extends KernelTestBase {
19 public static $modules = ['entity_test', 'user'];
22 * @covers ::isSatisfiedBy
24 public function testIsSatisfiedBy() {
25 $this->installEntitySchema('user');
27 $value = EntityTest::create([]);
28 // Assert that the entity has at least one violation.
29 $this->assertNotEmpty($value->validate());
30 // Assert that these violations do not prevent it from satisfying the
31 // requirements of another object.
32 $requirement = new ContextDefinition('any');
33 $context = EntityContext::fromEntity($value);
34 $this->assertTrue($requirement->isSatisfiedBy($context));