6
6
7
7
use GraphQL \Error \InvariantViolation ;
8
8
use Overblog \GraphQLBundle \Tests \Functional \TestCase ;
9
+ use Overblog \GraphQLBundle \Tests \VersionHelper ;
9
10
use Symfony \Component \HttpFoundation \File \UploadedFile ;
10
11
11
12
class UploadTest extends TestCase
@@ -111,9 +112,12 @@ public function testSerializationIsUnsupported(): void
111
112
112
113
public function testParseLiteralIsUnsupported (): void
113
114
{
114
- $ this ->expectException (InvariantViolation::class);
115
- $ this ->expectExceptionMessage ('Upload scalar literal unsupported. ' );
116
- $ this ->uploadRequest (
115
+ $ willThrowRawException = VersionHelper::compareWebonyxGraphQLPHPVersion ('0.13.1 ' , '< ' );
116
+ if ($ willThrowRawException ) {
117
+ $ this ->expectException (InvariantViolation::class);
118
+ $ this ->expectExceptionMessage ('Upload scalar literal unsupported. ' );
119
+ }
120
+ $ result = $ this ->uploadRequest (
117
121
[
118
122
'operations ' => [
119
123
'query ' => 'mutation { singleUpload(file: {}) } ' ,
@@ -123,6 +127,27 @@ public function testParseLiteralIsUnsupported(): void
123
127
],
124
128
['0 ' => 'a.txt ' ]
125
129
);
130
+ if (!$ willThrowRawException ) {
131
+ $ this ->assertEquals (
132
+ [
133
+ 'errors ' => [
134
+ [
135
+ 'message ' => 'Field "singleUpload" argument "file" requires type Upload, found {}; GraphQLUpload scalar literal unsupported. ' ,
136
+ 'extensions ' => [
137
+ 'category ' => 'graphql ' ,
138
+ ],
139
+ 'locations ' => [
140
+ [
141
+ 'line ' => 1 ,
142
+ 'column ' => 31 ,
143
+ ],
144
+ ],
145
+ ],
146
+ ],
147
+ ],
148
+ $ result
149
+ );
150
+ }
126
151
}
127
152
128
153
private function assertUpload (array $ expected , array $ parameters , array $ files , $ uri = '/ ' , $ json = true ): void
0 commit comments