function AjaxResponseTest::testPrepareResponseForIeFormRequestsWithFileUpload

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php \Drupal\Tests\Core\Ajax\AjaxResponseTest::testPrepareResponseForIeFormRequestsWithFileUpload()
  2. 8.9.x core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php \Drupal\Tests\Core\Ajax\AjaxResponseTest::testPrepareResponseForIeFormRequestsWithFileUpload()
  3. 11.x core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php \Drupal\Tests\Core\Ajax\AjaxResponseTest::testPrepareResponseForIeFormRequestsWithFileUpload()

Tests the support for IE specific headers in file uploads.

@cover ::prepareResponse

File

core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php, line 82

Class

AjaxResponseTest
@coversDefaultClass \Drupal\Core\Ajax\AjaxResponse @group Ajax

Namespace

Drupal\Tests\Core\Ajax

Code

public function testPrepareResponseForIeFormRequestsWithFileUpload() : void {
    $request = Request::create('/example', 'POST');
    $request->headers
        ->set('Accept', 'text/html');
    $response = new AjaxResponse([]);
    $response->headers
        ->set('Content-Type', 'application/json; charset=utf-8');
    $ajax_response_attachments_processor = $this->createMock('\\Drupal\\Core\\Render\\AttachmentsResponseProcessorInterface');
    $subscriber = new AjaxResponseSubscriber(fn() => $ajax_response_attachments_processor);
    $event = new ResponseEvent($this->createMock('\\Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MAIN_REQUEST, $response);
    $subscriber->onResponse($event);
    $this->assertEquals('text/html; charset=utf-8', $response->headers
        ->get('Content-Type'));
    $this->assertEquals('<textarea>[]</textarea>', $response->getContent());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.