public function MultiresponseNormalizerTest::testNormalize in Subrequests 3.x
Same name and namespace in other branches
- 8.2 tests/src/Unit/Normalizer/MultiresponseNormalizerTest.php \Drupal\Tests\subrequests\Normalizer\MultiresponseNormalizerTest::testNormalize()
@covers ::normalize
File
- tests/
src/ Unit/ Normalizer/ MultiresponseNormalizerTest.php, line 47
Class
- MultiresponseNormalizerTest
- @coversDefaultClass \Drupal\subrequests\Normalizer\MultiresponseNormalizer @group subrequests
Namespace
Drupal\Tests\subrequests\NormalizerCode
public function testNormalize() {
$sub_content_type = $this
->getRandomGenerator()
->string();
$data = [
Response::create('Foo!'),
Response::create('Bar'),
];
$actual = $this->sut
->normalize($data, NULL, [
'sub-content-type' => $sub_content_type,
]);
$parts = explode('; ', $actual['headers']['Content-Type']);
parse_str($parts[1], $parts);
$delimiter = substr($parts['boundary'], 1, strlen($parts['boundary']) - 2);
$this
->assertStringStartsWith('--' . $delimiter, $actual['content']);
$this
->assertStringEndsWith('--' . $delimiter . '--', $actual['content']);
$this
->assertRegExp("/\r\nFoo!\r\n/", $actual['content']);
$this
->assertRegExp("/\r\nBar\r\n/", $actual['content']);
}