function ItemResourceTestBase::createAnotherEntity

Same name and namespace in other branches
  1. 8.9.x core/modules/aggregator/tests/src/Functional/Rest/ItemResourceTestBase.php \Drupal\Tests\aggregator\Functional\Rest\ItemResourceTestBase::createAnotherEntity()

Creates another entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface Another entity based on $this->entity.

Overrides EntityResourceTestBase::createAnotherEntity

File

core/modules/aggregator/tests/src/Functional/Rest/ItemResourceTestBase.php, line 82

Class

ItemResourceTestBase
ResourceTestBase for Item entity. @group legacy

Namespace

Drupal\Tests\aggregator\Functional\Rest

Code

protected function createAnotherEntity() {
  $entity = $this->entity
    ->createDuplicate();
  $entity->setLink('https://www.example.org/');
  $label_key = $entity->getEntityType()
    ->getKey('label');
  if ($label_key) {
    $entity->set($label_key, $entity->label() . '_dupe');
  }
  $entity->save();
  return $entity;
}

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