You are here

protected function ContentEntityReferenceTest::getExpectedContentReferenceValue in Entity Share 8.3

Same name and namespace in other branches
  1. 8.2 modules/entity_share_client/tests/src/Functional/ContentEntityReferenceTest.php \Drupal\Tests\entity_share_client\Functional\ContentEntityReferenceTest::getExpectedContentReferenceValue()

Helper function.

After the value_callback is re-evaluated, the nid will be changed. So need a specific checker_callback.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity.

string $field_name: The field to retrieve the value.

Return value

array The expected value after import.

File

modules/entity_share_client/tests/src/Functional/ContentEntityReferenceTest.php, line 289

Class

ContentEntityReferenceTest
Functional test class for content entity reference field.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function getExpectedContentReferenceValue(ContentEntityInterface $entity, string $field_name) {

  // A little trick to dynamically get the correct value of referenced
  // entity, because our mock content UUID's respect this rule.
  // Otherwise we would need to add a new parameter to 'checker_callback'.
  $level = (int) str_replace('es_test_level_', '', $entity
    ->uuid());
  $target_uuid = 'es_test_level_' . ($level + 1);
  return [
    [
      'target_id' => $this
        ->getEntityId('node', $target_uuid),
    ],
  ];
}