You are here

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

@covers ::fetchDataByPropertyPath

File

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

Class

DataFetcherTest
Class DataFetcherTest.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testFetchingValueAtInvalidPosition() {
  $this
    ->expectException(MissingDataException::class);
  $this
    ->expectExceptionMessage("Unable to apply data selector 'field_integer.0.value' at 'field_integer.0'");
  $this->node->field_integer
    ->setValue([]);

  // This should trigger an exception.
  $this->dataFetcher
    ->fetchDataByPropertyPath($this->node
    ->getTypedData(), 'field_integer.0.value')
    ->getValue();
}