You are here

protected function BlazyCreationTestTrait::createReferencingEntity in Blazy 8

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/BlazyCreationTestTrait.php \Drupal\Tests\blazy\Traits\BlazyCreationTestTrait::createReferencingEntity()

Create referencing entity.

2 calls to BlazyCreationTestTrait::createReferencingEntity()
BlazyEntityReferenceFormatterTest::testFormatterDisplay in tests/src/Kernel/BlazyEntityReferenceFormatterTest.php
Tests the Blazy formatter display.
BlazyViewsFileTest::buildContents in tests/src/Kernel/Views/BlazyViewsFileTest.php
Build contents.

File

tests/src/Traits/BlazyCreationTestTrait.php, line 464

Class

BlazyCreationTestTrait
A Trait common for Blazy tests.

Namespace

Drupal\Tests\blazy\Traits

Code

protected function createReferencingEntity(array $data = []) {
  if (empty($data['values']) && $this->referencedEntity
    ->id()) {
    $data['values'] = [
      $this->entityFieldName => [
        [
          'target_id' => $this->referencedEntity
            ->id(),
        ],
      ],
    ];
  }
  return $this
    ->setUpContentWithItems($this->bundle, $data);
}