function EntityConstraintViolationListTest::setupConstraintListWithCompositeConstraint

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php \Drupal\Tests\Core\Entity\EntityConstraintViolationListTest::setupConstraintListWithCompositeConstraint()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php \Drupal\Tests\Core\Entity\EntityConstraintViolationListTest::setupConstraintListWithCompositeConstraint()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php \Drupal\Tests\Core\Entity\EntityConstraintViolationListTest::setupConstraintListWithCompositeConstraint()

Builds an entity constraint violation list with composite constraints.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: A fieldable entity.

Return value

\Drupal\Core\Entity\EntityConstraintViolationList The entity constraint violation list.

2 calls to EntityConstraintViolationListTest::setupConstraintListWithCompositeConstraint()
EntityConstraintViolationListTest::testFilterByFieldAccessWithCompositeConstraint in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFieldAccess
EntityConstraintViolationListTest::testFilterByFieldsWithCompositeConstraints in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFields

File

core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php, line 164

Class

EntityConstraintViolationListTest
@coversDefaultClass \Drupal\Core\Entity\EntityConstraintViolationList @group entity

Namespace

Drupal\Tests\Core\Entity

Code

protected function setupConstraintListWithCompositeConstraint(FieldableEntityInterface $entity) {
    $violations = [];
    // Add two violations to two specific fields.
    $violations[] = new ConstraintViolation('test name violation', '', [], '', 'name', 'invalid');
    $violations[] = new ConstraintViolation('test name violation2', '', [], '', 'name', 'invalid');
    $violations[] = new ConstraintViolation('test type violation', '', [], '', 'type', 'invalid');
    $violations[] = new ConstraintViolation('test type violation2', '', [], '', 'type', 'invalid');
    // Add two entity level specific violations with a compound constraint.
    $composite_constraint = new EntityTestCompositeConstraint();
    $violations[] = new ConstraintViolation('test composite violation', '', [], '', '', 'invalid', NULL, NULL, $composite_constraint);
    $violations[] = new ConstraintViolation('test composite violation2', '', [], '', '', 'invalid', NULL, NULL, $composite_constraint);
    return new EntityConstraintViolationList($entity, $violations);
}

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