@@ -69,7 +69,6 @@ public function testQuery() {
69
69
$ graphql ->registerType ('post ' , Entity \Post::class);
70
70
71
71
$ params = ['query ' => 'query { user(id: 1) { name, posts { title } }} ' ];
72
- $ content = $ response ->getData (true );
73
72
$ user = Entity \User::with ('posts ' )->find (1 );
74
73
$ posts = [];
75
74
@@ -79,13 +78,12 @@ public function testQuery() {
79
78
80
79
$ this ->call ('GET ' , '/graphql ' , $ params );
81
80
$ this ->seeJsonEquals ([
82
- $ this -> assertSame ( [
83
- ' user ' => [
84
- ' name ' => $ user -> name ,
85
- ' posts ' => $ posts
81
+ ' user ' => [
82
+ ' name ' => $ user -> name ,
83
+ ' posts ' => $ posts
84
+ ]
86
85
]
87
- ], $ content ['data ' ]);
88
- ]);
86
+ ], $ response );
89
87
}
90
88
91
89
/**
@@ -102,17 +100,33 @@ public function testMutation() {
102
100
103
101
$ params = ['query ' => 'mutation { updateName : user(id: 1, name : "Test") { id, name } } ' ];
104
102
$ this ->json ('POST ' , '/graphql ' , $ params );
105
- $ content = $ response ->getData (true );
106
103
$ entity = Entity \User::find (1 );
107
104
108
105
$ this ->seeJsonEquals ([
109
- $ this -> assertArrayNotHasKey ( ' errors ' , $ content );
110
- $ this -> assertSame ( [
111
- ' updateName ' => [
112
- ' id ' => ( string ) $ entity ->getKey (),
113
- ' name ' => $ entity -> name
106
+ ' data ' => [
107
+ ' updateName ' => [
108
+ ' id ' => ( string ) $ entity -> getKey (),
109
+ ' name ' => $ entity ->name
110
+ ]
114
111
]
115
- ], $ content ['data ' ]);
116
- ]);
112
+ ], $ response );
113
+ }
114
+
115
+ /**
116
+ * Backward compatibility between 5.3 and 5.4
117
+ *
118
+ * @param array $data
119
+ * @param mixed $response
120
+ *
121
+ * @return void
122
+ */
123
+ public function assertJsonEquals (array $ data , $ response ) {
124
+ if (method_exists ($ response , 'assertJson ' )) {
125
+ $ response ->assertJson ($ data );
126
+ }
127
+
128
+ if (method_exists ($ response , 'seeJsonEquals ' )) {
129
+ $ response ->seeJsonEquals ($ data );
130
+ }
117
131
}
118
132
}
0 commit comments