You are here

public function ContextDefinitionTest::testIsSatisfiedBy in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\ContextDefinitionTest::testIsSatisfiedBy()
  2. 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 25

Class

ContextDefinitionTest
@coversDefaultClass \Drupal\Core\Plugin\Context\ContextDefinition @group Plugin

Namespace

Drupal\KernelTests\Core\Plugin

Code

public function testIsSatisfiedBy() {
  $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));
}