function EntityConstraintViolationListTest::testFilterByFieldAccessWithCompositeConstraint

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

@covers ::filterByFieldAccess

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testFilterByFieldAccessWithCompositeConstraint() {
    $account = $this->prophesize('\\Drupal\\Core\\Session\\AccountInterface')
        ->reveal();
    $entity = $this->setupEntity($account);
    $constraint_list = $this->setupConstraintListWithCompositeConstraint($entity);
    $violations = iterator_to_array($constraint_list);
    $this->assertSame($constraint_list->filterByFieldAccess($account), $constraint_list);
    $this->assertCount(4, $constraint_list);
    $this->assertArrayEquals(array_values(iterator_to_array($constraint_list)), [
        $violations[2],
        $violations[3],
        $violations[4],
        $violations[5],
    ]);
}

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