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