You are here

public function RecursiveContextualValidatorTest::testRecursiveValidate in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\KernelTests\Core\TypedData\RecursiveContextualValidatorTest::testRecursiveValidate()

Tests recursive validation against given constraints against an entity.

File

core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php, line 36

Class

RecursiveContextualValidatorTest
@coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator @group Validation

Namespace

Drupal\KernelTests\Core\TypedData

Code

public function testRecursiveValidate() {
  $entity = EntityTest::create();
  $adapter = EntityAdapter::createFromEntity($entity);

  // This would trigger the ValidReferenceConstraint due to EntityTest
  // defaulting uid to 1, which doesn't exist. Ensure that we don't get a
  // violation for that.
  $this
    ->assertCount(0, \Drupal::typedDataManager()
    ->getValidator()
    ->validate($adapter, $adapter
    ->getConstraints()));
}