44
55use GraphQL \Error \InvariantViolation ;
66use Overblog \GraphQLBundle \Tests \Functional \TestCase ;
7+ use Overblog \GraphQLBundle \Tests \VersionHelper ;
78use Symfony \Component \HttpFoundation \File \UploadedFile ;
89
910class UploadTest extends TestCase
@@ -109,9 +110,12 @@ public function testSerializationIsUnsupported()
109110
110111 public function testParseLiteralIsUnsupported ()
111112 {
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 (
115119 [
116120 'operations ' => [
117121 'query ' => 'mutation { singleUpload(file: {}) } ' ,
@@ -121,6 +125,27 @@ public function testParseLiteralIsUnsupported()
121125 ],
122126 ['0 ' => 'a.txt ' ]
123127 );
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+ }
124149 }
125150
126151 private function assertUpload (array $ expected , array $ parameters , array $ files , $ uri = '/ ' , $ json = true )
0 commit comments