function RecursiveContextualValidatorTest::testRecursiveValidate

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\KernelTests\Core\TypedData\RecursiveContextualValidatorTest::testRecursiveValidate()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\KernelTests\Core\TypedData\RecursiveContextualValidatorTest::testRecursiveValidate()
  3. 10 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 38

Class

RecursiveContextualValidatorTest
@coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator[[api-linebreak]] @group Validation

Namespace

Drupal\KernelTests\Core\TypedData

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.