You are here

public function DataFetcherTest::testFetchingValueAtValidPositions in Typed Data API enhancements 8

@covers ::fetchDataByPropertyPath

File

tests/src/Kernel/DataFetcherTest.php, line 176

Class

DataFetcherTest
Class DataFetcherTest.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testFetchingValueAtValidPositions() {
  $this->node->field_integer
    ->setValue([
    '0' => 1,
    '1' => 2,
  ]);
  $fetched_value = $this->dataFetcher
    ->fetchDataByPropertyPath($this->node
    ->getTypedData(), 'field_integer.0.value')
    ->getValue();
  $this
    ->assertEquals($fetched_value, 1);
  $fetched_value = $this->dataFetcher
    ->fetchDataByPropertyPath($this->node
    ->getTypedData(), 'field_integer.1.value')
    ->getValue();
  $this
    ->assertEquals($fetched_value, 2);
}