You are here

public function DataDefinitionFetcherTest::testFetchingAtInvalidPosition in Typed Data API enhancements 8

@covers ::fetchDefinitionByPropertyPath

File

tests/src/Kernel/DataDefinitionFetcherTest.php, line 258

Class

DataDefinitionFetcherTest
Tests that data fetcher definition fetching functions work correctly.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testFetchingAtInvalidPosition() {
  $this
    ->expectException(InvalidArgumentException::class);
  $this
    ->expectExceptionMessage("The data selector 'unknown_property' cannot be applied because the definition of type 'integer' is not a list or a complex structure");
  $list_definition = $this->typedDataManager
    ->createListDataDefinition('integer');

  // This should trigger an exception.
  $this->dataFetcher
    ->fetchDefinitionByPropertyPath($list_definition, 'unknown_property');
}