function EntityConstraintViolationListTest::setupEntity

Same name and namespace in other branches
  1. 11.x 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. 9 core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php \Drupal\Tests\Core\Entity\EntityConstraintViolationListTest::setupEntity()
  4. 8.9.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\Entity\FieldableEntityInterface A fieldable entity.

5 calls to EntityConstraintViolationListTest::setupEntity()
EntityConstraintViolationListTest::testFilterByFieldAccess in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
Tests filter by field access.
EntityConstraintViolationListTest::testFilterByFieldAccessWithCompositeConstraint in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
Tests filter by field access with composite constraint.
EntityConstraintViolationListTest::testFilterByFields in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
Tests filter by fields.
EntityConstraintViolationListTest::testFilterByFieldsWithCompositeConstraints in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
Tests filter by fields with composite constraints.
EntityConstraintViolationListTest::testFindByCodes in core/tests/Drupal/Tests/Core/Entity/EntityConstraintViolationListTest.php
Tests find by codes.

File

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

Class

EntityConstraintViolationListTest
Tests Drupal\Core\Entity\EntityConstraintViolationList.

Namespace

Drupal\Tests\Core\Entity

Code

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

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