You are here

InvalidPayloadTest.php in GraphQL 8.3

Same filename and directory in other branches
  1. 8.4 tests/src/Kernel/Framework/InvalidPayloadTest.php

File

tests/src/Kernel/Framework/InvalidPayloadTest.php
View source
<?php

namespace Drupal\Tests\graphql\Kernel\Framework;

use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
use Symfony\Component\HttpFoundation\Request;

/**
 * Invalid payloads should not trigger a PHP error, but be handled as empty.
 *
 * @group graphql
 */
class InvalidPayloadTest extends GraphQLTestBase {
  public function testEmptyPayload() {

    /** @var \Symfony\Component\HttpFoundation\Response $result */
    $result = $this->container
      ->get('http_kernel')
      ->handle(Request::create('/graphql', 'POST', [], [], [], [], '{ invalid'));
    $this
      ->assertJson($result
      ->getContent(), json_encode([
      'errors' => [
        'message' => "GraphQL Request must include at least one of those two parameters: \\u0022query\\u0022 or \\u0022queryId\\u0022\"",
        'category' => "request",
      ],
    ]));
  }

}

Classes

Namesort descending Description
InvalidPayloadTest Invalid payloads should not trigger a PHP error, but be handled as empty.