Skip to content

Commit e6e1738

Browse files
committed
GuzzleTranscoderTest::testConvertResponse: Clean up
1 parent 36bb394 commit e6e1738

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

tests/GuzzleTranscoderTest.php

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,20 @@ public function testConvertResponse(): void {
189189
'replaceContent' => true,
190190
]),
191191
];
192-
foreach ($tests as $name) {
193-
$input = __DIR__ . "/resources/iso-8859-1-{$name}";
192+
foreach ($tests as $type) {
193+
$input = __DIR__ . "/resources/iso-8859-1-{$type}";
194194
$c = file_get_contents($input);
195-
$arr = $this->splitHeadersAndContentFromHttpResponseString($c);
196-
$headers = $arr['headers'];
197-
$body = $arr['body'];
198-
/* @var GuzzleTranscoder */
199-
foreach ($converters as $file => $converter) {
200-
$expected = __DIR__ . "/resources/utf8-{$name}-{$file}";
195+
['headers' => $headers, 'body' => $body] = $this->splitHeadersAndContentFromHttpResponseString($c);
196+
197+
foreach ($converters as $converterName => $converter) {
198+
$expected = __DIR__ . "/resources/utf8-{$type}-{$converterName}";
201199
$c = file_get_contents($expected);
202-
$arr = $this->splitHeadersAndContentFromHttpResponseString($c);
203-
$expectedHeaders = $arr['headers'];
204-
$expectedBody = $arr['body'];
200+
['headers' => $expectedHeaders, 'body' => $expectedBody] = $this->splitHeadersAndContentFromHttpResponseString($c);
205201
$res = $converter->convertResponse($headers, $body);
206-
$msg = [
207-
"Error in test $name - $file:",
208-
'Input headers : ' . json_encode($headers),
209-
'Expected headers: ' . json_encode($expectedHeaders),
210-
'Actual headers : ' . json_encode($res['headers']),
211-
];
212-
$msg = implode("\n", $msg);
213-
$this->assertEquals($res['headers'], $expectedHeaders, $msg);
214-
$msg = [
215-
"Error in test $name - $file:",
216-
"Input body :\n" . $body . "\n",
217-
"Expected body :\n" . $expectedBody . "\n",
218-
"Actual body :\n" . $res['content'] . "\n",
219-
];
220-
$msg = implode("\n", $msg);
221-
$this->assertEquals($expectedBody, $res['content'], $msg);
202+
203+
$this->assertNotNull($res, "Unable to convert response for {$type} using {$converterName}.");
204+
$this->assertSame($expectedHeaders, $res['headers'], "Response headers do not match for {$type} using {$converterName}.");
205+
$this->assertSame($expectedBody, $res['content'], "Response body does not match for {$type} using {$converterName}.");
222206
}
223207
}
224208
}

0 commit comments

Comments
 (0)