You are here

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

@covers ::fetchDataByPropertyPath

File

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

Class

DataFetcherTest
Class DataFetcherTest.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testFetchingFromEmptyData() {
  $this
    ->expectException(MissingDataException::class);
  $this
    ->expectExceptionMessage("Unable to apply data selector 'field_integer.0.value' at 'field_integer': Unable to get property field_integer as no entity has been provided.");
  $data_empty = $this->typedDataManager
    ->create(EntityDataDefinition::create('node'));

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