function EntityFieldValueTraitTest::getFieldValue

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php \Drupal\KernelTests\Core\Entity\EntityFieldValueTraitTest::getFieldValue()

Calls protected getFieldValue() method via reflection.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityFieldValueTraitTest.php, line 35

Class

EntityFieldValueTraitTest
Tests the EntityFieldValueTrait.

Namespace

Drupal\KernelTests\Core\Entity

Code

private function getFieldValue(User $account, string $field_name, string $property, int $delta = 0) : mixed {
  $reflection = new \ReflectionClass($account);
  return $reflection->getMethod('getFieldValue')
    ->invoke($account, $field_name, $property, $delta);
}

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