You are here

public function EntityReferenceTest::testResolveEntityReference in GraphQL 8.4

@covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Field\EntityReference::resolve

File

tests/src/Kernel/DataProducer/EntityReferenceTest.php, line 76

Class

EntityReferenceTest
Data producers Field test class.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer

Code

public function testResolveEntityReference() : void {
  $result = $this
    ->executeDataProducer('entity_reference', [
    'entity' => $this->node,
    'field' => 'field_test1_to_test2',
    'access' => TRUE,
    'access_operation' => 'view',
  ]);
  $this
    ->assertEquals($this->referenced_node
    ->id(), reset($result)
    ->id());
  $this
    ->assertEquals('Dolor2', reset($result)
    ->label());
  $result = $this
    ->executeDataProducer('entity_reference', [
    'entity' => $this->node,
    'field' => 'field_test1_to_test2',
    'access' => TRUE,
    'access_operation' => 'view',
    'language' => 'fr',
  ]);
  $this
    ->assertEquals($this->referenced_node
    ->id(), reset($result)
    ->id());
  $this
    ->assertEquals('Dolor2 French', reset($result)
    ->label());
}