public function EntityMutationTest::testUpdateEntityMutation in GraphQL 8.3
Test entity updates.
File
- modules/
graphql_core/ tests/ src/ Kernel/ EntityMutation/ EntityMutationTest.php, line 157
Class
- EntityMutationTest
- Test abstract entity mutation classes.
Namespace
Drupal\Tests\graphql_core\Kernel\EntityMutationCode
public function testUpdateEntityMutation() {
$this
->mockMutation('updateNode', [
'name' => 'updateNode',
'entity_type' => 'node',
'entity_bundle' => 'test',
'arguments' => [
'id' => 'String',
'input' => 'NodeInput',
],
'type' => 'EntityCrudOutput',
], function ($source, $args, $context, $info) {
return [
'title' => $args['input']['title'],
];
});
$this
->createNode([
'title' => 'Old title',
'status' => 1,
'type' => 'test',
'body' => [
'value' => 'Old body',
],
]);
$this
->assertResults('mutation ($node: NodeInput!, $nid: String!) { updateNode(id: $nid, input: $node) { entity { entityLabel } } }', [
'nid' => '1',
'node' => [
'title' => 'Test',
],
], [
'updateNode' => [
'entity' => [
'entityLabel' => 'Test',
],
],
], $this
->defaultMutationCacheMetaData());
$this
->assertEquals('Test', Node::load(1)
->getTitle());
}