3
3
namespace TheCodingMachine \GraphQLite \Http ;
4
4
5
5
use Exception ;
6
+ use GraphQL \Error \ClientAware ;
6
7
use GraphQL \Error \Error ;
7
8
use GraphQL \Executor \ExecutionResult ;
8
9
use PHPUnit \Framework \TestCase ;
@@ -32,6 +33,19 @@ public function testDecideHttpStatusCode(): void
32
33
$ exception600 = new Exception ('foo ' , 600 );
33
34
$ errorCode600 = new Error ('Foo ' , null , null , null , null , $ exception600 );
34
35
36
+ $ clientAwareException = new class extends Exception implements ClientAware {
37
+ public function isClientSafe ()
38
+ {
39
+ return true ;
40
+ }
41
+
42
+ public function getCategory ()
43
+ {
44
+ return 'foo ' ;
45
+ }
46
+ };
47
+ $ clientAwareError = new Error ('Foo ' , null , null , null , null , $ clientAwareException );
48
+
35
49
$ executionResult = new ExecutionResult (null , [ $ errorCode0 ]);
36
50
$ this ->assertSame (500 , $ codeDecider ->decideHttpStatusCode ($ executionResult ));
37
51
@@ -40,5 +54,8 @@ public function testDecideHttpStatusCode(): void
40
54
41
55
$ executionResult = new ExecutionResult (null , [ $ graphqlError ]);
42
56
$ this ->assertSame (400 , $ codeDecider ->decideHttpStatusCode ($ executionResult ));
57
+
58
+ $ executionResult = new ExecutionResult (null , [ $ clientAwareError ]);
59
+ $ this ->assertSame (400 , $ codeDecider ->decideHttpStatusCode ($ executionResult ));
43
60
}
44
61
}
0 commit comments