function EntityConstraintViolationListTest::setupEntity

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

Builds the entity.

Parameters

\Drupal\Core\Session\AccountInterface $account: An account.

Return value

\Drupal\Core\Field\FieldItemListInterface A fieldable entity.

4 calls to EntityConstraintViolationListTest::setupEntity()
EntityConstraintViolationListTest::testFilterByFieldAccess in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFieldAccess
EntityConstraintViolationListTest::testFilterByFieldAccessWithCompositeConstraint in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFieldAccess
EntityConstraintViolationListTest::testFilterByFields in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFields
EntityConstraintViolationListTest::testFilterByFieldsWithCompositeConstraints in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
@covers ::filterByFields

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

protected function setupEntity(AccountInterface $account) {
    $prophecy = $this->prophesize('\\Drupal\\Core\\Field\\FieldItemListInterface');
    $prophecy->access('edit', $account)
        ->willReturn(FALSE);
    $name_field_item_list = $prophecy->reveal();
    $prophecy = $this->prophesize('\\Drupal\\Core\\Field\\FieldItemListInterface');
    $prophecy->access('edit', $account)
        ->willReturn(TRUE);
    $type_field_item_list = $prophecy->reveal();
    $prophecy = $this->prophesize('\\Drupal\\Core\\Entity\\FieldableEntityInterface');
    $prophecy->hasField('name')
        ->willReturn(TRUE);
    $prophecy->hasField('type')
        ->willReturn(TRUE);
    $prophecy->get('name')
        ->willReturn($name_field_item_list);
    $prophecy->get('type')
        ->willReturn($type_field_item_list);
    return $prophecy->reveal();
}

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