You are here

public function EntityDefinitionTest::testConfiguredFieldFilter in GraphQL 8.4

Tests that filtering configured field definitions works.

File

tests/src/Kernel/DataProducer/EntityDefinitionTest.php, line 567

Class

EntityDefinitionTest
Test the entity_definition data producer and friends.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer

Code

public function testConfiguredFieldFilter() : void {
  $query = <<<GQL
      query {
        entityDefinition(entity_type: "node", bundle: "article", field_types: FIELD_CONFIG) {
          label
          fields {
            id
            label
            description
            type
            required
            multiple
            maxNumItems
            status
            defaultValue
            isReference
            isHidden
            weight
          }
        }
      }
GQL;
  $expectedResult = $this->fullDefinitionResult;

  // Only the configured field should show up.
  $configured_field = $expectedResult['entityDefinition']['fields'][18];
  $expectedResult['entityDefinition']['fields'] = [
    $configured_field,
  ];
  $this->defaultCacheTags[] = 'config:field.field.node.article.field_test';
  $this
    ->assertResults($query, [], $expectedResult);
}