@@ -113,11 +113,12 @@ public function assertExact(array $data)
113
113
*/
114
114
public function assertSimilar (array $ data )
115
115
{
116
- $ actual = json_encode (Arr::sortRecursive (
117
- (array ) $ this ->decoded
118
- ));
116
+ $ actual = json_encode (
117
+ Arr::sortRecursive ((array ) $ this ->decoded ),
118
+ JSON_UNESCAPED_UNICODE
119
+ );
119
120
120
- PHPUnit::assertEquals (json_encode (Arr::sortRecursive ($ data )), $ actual );
121
+ PHPUnit::assertEquals (json_encode (Arr::sortRecursive ($ data ), JSON_UNESCAPED_UNICODE ), $ actual );
121
122
122
123
return $ this ;
123
124
}
@@ -130,17 +131,18 @@ public function assertSimilar(array $data)
130
131
*/
131
132
public function assertFragment (array $ data )
132
133
{
133
- $ actual = json_encode (Arr::sortRecursive (
134
- (array ) $ this ->decoded
135
- ));
134
+ $ actual = json_encode (
135
+ Arr::sortRecursive ((array ) $ this ->decoded ),
136
+ JSON_UNESCAPED_UNICODE
137
+ );
136
138
137
139
foreach (Arr::sortRecursive ($ data ) as $ key => $ value ) {
138
140
$ expected = $ this ->jsonSearchStrings ($ key , $ value );
139
141
140
142
PHPUnit::assertTrue (
141
143
Str::contains ($ actual , $ expected ),
142
144
'Unable to find JSON fragment: ' .PHP_EOL .PHP_EOL .
143
- '[ ' .json_encode ([$ key => $ value ]).'] ' .PHP_EOL .PHP_EOL .
145
+ '[ ' .json_encode ([$ key => $ value ], JSON_UNESCAPED_UNICODE ).'] ' .PHP_EOL .PHP_EOL .
144
146
'within ' .PHP_EOL .PHP_EOL .
145
147
"[ {$ actual }]. "
146
148
);
@@ -162,17 +164,18 @@ public function assertMissing(array $data, $exact = false)
162
164
return $ this ->assertMissingExact ($ data );
163
165
}
164
166
165
- $ actual = json_encode (Arr::sortRecursive (
166
- (array ) $ this ->decoded
167
- ));
167
+ $ actual = json_encode (
168
+ Arr::sortRecursive ((array ) $ this ->decoded ),
169
+ JSON_UNESCAPED_UNICODE
170
+ );
168
171
169
172
foreach (Arr::sortRecursive ($ data ) as $ key => $ value ) {
170
173
$ unexpected = $ this ->jsonSearchStrings ($ key , $ value );
171
174
172
175
PHPUnit::assertFalse (
173
176
Str::contains ($ actual , $ unexpected ),
174
177
'Found unexpected JSON fragment: ' .PHP_EOL .PHP_EOL .
175
- '[ ' .json_encode ([$ key => $ value ]).'] ' .PHP_EOL .PHP_EOL .
178
+ '[ ' .json_encode ([$ key => $ value ], JSON_UNESCAPED_UNICODE ).'] ' .PHP_EOL .PHP_EOL .
176
179
'within ' .PHP_EOL .PHP_EOL .
177
180
"[ {$ actual }]. "
178
181
);
@@ -189,9 +192,10 @@ public function assertMissing(array $data, $exact = false)
189
192
*/
190
193
public function assertMissingExact (array $ data )
191
194
{
192
- $ actual = json_encode (Arr::sortRecursive (
193
- (array ) $ this ->decoded
194
- ));
195
+ $ actual = json_encode (
196
+ Arr::sortRecursive ((array ) $ this ->decoded ),
197
+ JSON_UNESCAPED_UNICODE
198
+ );
195
199
196
200
foreach (Arr::sortRecursive ($ data ) as $ key => $ value ) {
197
201
$ unexpected = $ this ->jsonSearchStrings ($ key , $ value );
@@ -203,7 +207,7 @@ public function assertMissingExact(array $data)
203
207
204
208
PHPUnit::fail (
205
209
'Found unexpected JSON fragment: ' .PHP_EOL .PHP_EOL .
206
- '[ ' .json_encode ($ data ).'] ' .PHP_EOL .PHP_EOL .
210
+ '[ ' .json_encode ($ data, JSON_UNESCAPED_UNICODE ).'] ' .PHP_EOL .PHP_EOL .
207
211
'within ' .PHP_EOL .PHP_EOL .
208
212
"[ {$ actual }]. "
209
213
);
@@ -322,9 +326,9 @@ protected function reorderAssocKeys(array $data)
322
326
*/
323
327
protected function assertJsonMessage (array $ data )
324
328
{
325
- $ expected = json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES );
329
+ $ expected = json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
326
330
327
- $ actual = json_encode ($ this ->decoded , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES );
331
+ $ actual = json_encode ($ this ->decoded , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
328
332
329
333
return 'Unable to find JSON: ' .PHP_EOL .PHP_EOL .
330
334
"[ {$ expected }] " .PHP_EOL .PHP_EOL .
@@ -341,7 +345,7 @@ protected function assertJsonMessage(array $data)
341
345
*/
342
346
protected function jsonSearchStrings ($ key , $ value )
343
347
{
344
- $ needle = substr (json_encode ([$ key => $ value ]), 1 , -1 );
348
+ $ needle = Str:: substr (json_encode ([$ key => $ value ], JSON_UNESCAPED_UNICODE ), 1 , -1 );
345
349
346
350
return [
347
351
$ needle .'] ' ,
0 commit comments