Skip to content

test(EntityDefinition): Add test case for base field and configured field filter#1140

Merged
klausi merged 8 commits intodrupal-graphql:8.x-4.xfrom
klausi:def-field-types
Jan 12, 2021
Merged

test(EntityDefinition): Add test case for base field and configured field filter#1140
klausi merged 8 commits intodrupal-graphql:8.x-4.xfrom
klausi:def-field-types

Conversation

@klausi
Copy link
Copy Markdown
Contributor

@klausi klausi commented Dec 27, 2020

Follow-up for #991 , adding 2 test cases.

Copy link
Copy Markdown
Contributor

@rthideaway rthideaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one, thanks!

$expectedResult = $this->fullDefinitionResult;
// Remove the one configured field that should not be in the list of base
// fields.
unset($expectedResult['entityDefinition']['fields'][18]);
Copy link
Copy Markdown
Contributor

@rthideaway rthideaway Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could split the list of expected fields result into two variables - base fields result and configurable fields result. then use array_merge if we need to compare both of them:

protected function getEntityDefinitionResult(string $type, array $result) {
  return [
    'entityDefinition' =>
      [
        'label' => $type,
        'fields' => $result,
      ]
  ];
}
$fullDefinitionResult = $this->getEntityDefinitionResult('Content', array_merge($this->baseFieldResult, $this->configFieldResult));

or if need a specific one:

$baseFieldDefinitionResult = $this->getEntityDefinitionResult('Content', $this->baseFieldResult);

but fine for me this way as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is just one configured field, so I would leave it as is.

@klausi klausi merged commit fdadd90 into drupal-graphql:8.x-4.x Jan 12, 2021
@klausi klausi deleted the def-field-types branch January 12, 2021 09:39
klausi added a commit to klausi/graphql that referenced this pull request Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants