You are here

public function EntityFieldValueTest::testText in GraphQL 8.3

Test a simple text field.

File

modules/graphql_core/tests/src/Kernel/Entity/EntityFieldValueTest.php, line 79

Class

EntityFieldValueTest
Test basic entity fields.

Namespace

Drupal\Tests\graphql_core\Kernel\Entity

Code

public function testText() {
  $this
    ->addField('text', "field_text", FALSE);
  $this
    ->mockNode([
    'field_text' => [
      'value' => 'Foo',
    ],
  ]);
  $this
    ->assertGraphQLFields([
    [
      'NodeTest',
      'fieldText',
      'FieldNodeTestFieldText',
    ],
    [
      'FieldNodeTestFieldText',
      'value',
      'String',
    ],
    [
      'FieldNodeTestFieldText',
      'processed',
      'String',
    ],
    [
      'FieldNodeTestFieldText',
      'format',
      'String',
    ],
  ]);
  $query = <<<GQL
query {
  node {
    fieldText {
      value
      processed
      format
    }
  }
}
GQL;
  $metadata = $this
    ->defaultCacheMetaData();
  $this
    ->assertResults($query, [], [
    'node' => [
      'fieldText' => [
        'value' => 'Foo',
        'processed' => "<p>Foo</p>\n",
        'format' => null,
      ],
    ],
  ], $metadata);
}