function EntityFieldValueTraitTest::testGetFieldValueWithDelta

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

Tests getFieldValue() with delta parameter.

File

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

Class

EntityFieldValueTraitTest
Tests the EntityFieldValueTrait.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testGetFieldValueWithDelta() : void {
  $account = User::create([
    'name' => 'user1',
  ]);
  $account->save();
  $this->assertSame('user1', $this->getFieldValue($account, 'name', 'value', 0));
  $this->assertNull($this->getFieldValue($account, 'name', 'value', 1));
}

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