You are here

public function DataFetcherAutocompleteTest::testGlobalAutocomplete in Typed Data API enhancements 8

Tests that autocompletion of global context variables works.

@covers ::autocompletePropertyPath

File

tests/src/Kernel/DataFetcherAutocompleteTest.php, line 128

Class

DataFetcherAutocompleteTest
Tests that data fetcher autocomplete function works correctly.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testGlobalAutocomplete() {
  $definitions = [
    '@node.node_route_context:node' => $this->globalNodeDefinition,
  ];
  $results = $this->dataFetcher
    ->autocompletePropertyPath($definitions, '@n');
  $this
    ->assertSame([
    [
      'value' => '@node.node_route_context:node',
      'label' => '@node.node_route_context:node (Node from URL)',
    ],
    [
      'value' => '@node.node_route_context:node.',
      'label' => '@node.node_route_context:node... (Node from URL)',
    ],
  ], $results);
}