GraphQlMutationTest.php 817 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\GraphQl\TestModule;
  8. use Magento\TestFramework\TestCase\GraphQlAbstract;
  9. /**
  10. * Make sure that it is possible to use GraphQL mutations in Magento
  11. */
  12. class GraphQlMutationTest extends GraphQlAbstract
  13. {
  14. public function testMutation()
  15. {
  16. $id = 3;
  17. $query = <<<MUTATION
  18. mutation {
  19. testItem(id: {$id}) {
  20. item_id,
  21. name,
  22. integer_list
  23. }
  24. }
  25. MUTATION;
  26. $response = $this->graphQlQuery($query);
  27. $this->assertArrayHasKey('testItem', $response);
  28. $testItem = $response['testItem'];
  29. $this->assertArrayHasKey('integer_list', $testItem);
  30. $this->assertEquals([4, 5, 6], $testItem['integer_list']);
  31. }
  32. }