// database, then set the User-Agent header to the database prefix so that
// any calls to other Drupal pages will run the test-prefixed database. The
// user agent is used to ensure that multiple testing sessions running at
// the same time won't interfere with each other as they would if the
// database prefix were stored statically in a file or database variable.
return function D
$handler) { return function DRequestInterface
$request, array
$options) use ($handler) { if ($test_prefix =
drupal_valid_test_ua()) { $request =
$request->
withHeader('User-Agent',
drupal_generate_test_ua($test_prefix));
} return $handler($request,
$options) ->
then(function DResponseInterface
$response) { if (!
drupal_valid_test_ua()) { return $response;
} $headers =
$response->
getHeaders();
foreach ($headers as $header_name =>
$header_values) { if (preg_match('/^X-Drupal-Assertion-[0-9]+$/',
$header_name,
$matches)) { foreach ($header_values as $header_value) { $parameters =
unserialize(urldecode($header_value));
if (count($parameters) === 3
) { if ($parameters[1
] === 'User deprecated function'
) { // Fire the same deprecation message to allow it to be