You are here

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

@covers ::fetchDefinitionByPropertyPath

File

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

Class

DataDefinitionFetcherTest
Tests that data fetcher definition fetching functions work correctly.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testFetchingFromPrimitive() {
  $this
    ->expectException(InvalidArgumentException::class);
  $this
    ->expectExceptionMessage("The data selector 'unknown_property' cannot be applied because the definition of type 'string' is not a list or a complex structure");
  $definition = $this->nodeDefinition
    ->getPropertyDefinition('title')
    ->getItemDefinition()
    ->getPropertyDefinition('value');

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