return $response instanceof HtmlResponse &&
empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'
],
array_keys($response->
getAttachments())));
})) ->
will(function D
$args) { /** @var \Symfony\Component\HttpFoundation\Response|\Drupal\Core\Render\AttachmentsInterface $response */
$response =
$args[0
];
// Simulate its actual behavior.
$attachments =
array_diff_key($response->
getAttachments(),
['html_response_attachment_placeholders' => TRUE
]);
$response->
setContent('processed'
);
$response->
setAttachments($attachments);
return $response;
}) ->
shouldBeCalled();
$big_pipe_response_attachments_processor =
$this->
createBigPipeResponseAttachmentsProcessor($html_response_attachments_processor);
$processed_big_pipe_response =
$big_pipe_response_attachments_processor->
processAttachments($big_pipe_response);
// The secondary expectation of this test: the original (passed in) response
// object remains unchanged, the processed (returned) response object has
// the expected values.
$this->
assertSame($attachments,
$big_pipe_response->
getAttachments(), 'Attachments of original response object MUST NOT be changed.'
);
$this->
assertEquals('original',
$big_pipe_response->
getContent(), 'Content of original response object MUST NOT be changed.'
);
$this->
assertEquals(array_diff_key($attachments,
['html_response_attachment_placeholders' => TRUE
]),
$processed_big_pipe_response->
getAttachments(), 'Attachments of returned (processed) response object MUST be changed.'
);
$this->
assertEquals('processed',
$processed_big_pipe_response->
getContent(), 'Content of returned (processed) response object MUST be changed.'
);
}