Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions tests/Functional/Upload/UploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use GraphQL\Error\InvariantViolation;
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
use Overblog\GraphQLBundle\Tests\VersionHelper;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class UploadTest extends TestCase
Expand Down Expand Up @@ -112,42 +111,45 @@ public function testSerializationIsUnsupported(): void

public function testParseLiteralIsUnsupported(): void
{
$willThrowRawException = VersionHelper::compareWebonyxGraphQLPHPVersion('0.13.1', '<');
if ($willThrowRawException) {
try {
$result = $this->uploadRequest(
[
'operations' => [
'query' => 'mutation { singleUpload(file: {}) }',
'variables' => ['file' => null],
],
'map' => ['0' => ['variables.file']],
],
['0' => 'a.txt']
);
} catch (\Exception $e) {
// webonyx/graphql-php (<0.13.1) does not generate error result
$this->expectException(InvariantViolation::class);
$this->expectExceptionMessage('Upload scalar literal unsupported.');

throw $e;
}
$result = $this->uploadRequest(

// webonyx/graphql-php (>=0.13.1) catches exceptions and generates error result
$this->assertEquals(
[
'operations' => [
'query' => 'mutation { singleUpload(file: {}) }',
'variables' => ['file' => null],
],
'map' => ['0' => ['variables.file']],
],
['0' => 'a.txt']
);
if (!$willThrowRawException) {
$this->assertEquals(
[
'errors' => [
[
'message' => 'Field "singleUpload" argument "file" requires type Upload, found {}; GraphQLUpload scalar literal unsupported.',
'extensions' => [
'category' => 'graphql',
],
'locations' => [
[
'line' => 1,
'column' => 31,
],
'errors' => [
[
'message' => 'Field "singleUpload" argument "file" requires type Upload, found {}; GraphQLUpload scalar literal unsupported.',
'extensions' => [
'category' => 'graphql',
],
'locations' => [
[
'line' => 1,
'column' => 31,
],
],
],
],
$result
);
}
],
$result
);
}

private function assertUpload(array $expected, array $parameters, array $files, $uri = '/', $json = true): void
Expand Down
36 changes: 0 additions & 36 deletions tests/VersionHelper.php

This file was deleted.