function RecursiveContextualValidatorTest::testRecursiveValidate

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

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