Exemplo n.º 1
0
 /**
  * Tests the support for IE specific headers in file uploads.
  *
  * @cover ::prepareResponse
  */
 public function testPrepareResponseForIeFormRequestsWithFileUpload()
 {
     $request = Request::create('/example', 'POST');
     $request->headers->set('Accept', 'text/html');
     $response = new AjaxResponse([]);
     $response->headers->set('Content-Type', 'application/json; charset=utf-8');
     $response->prepare($request);
     $this->assertEquals('text/html; charset=utf-8', $response->headers->get('Content-Type'));
     $this->assertEquals($response->getContent(), '<textarea>[]</textarea>');
 }
Exemplo n.º 2
0
 /**
  * Tests the support for IE specific headers in file uploads.
  *
  * @cover ::prepareResponse
  */
 public function testPrepareResponseForIeFormRequestsWithFileUpload()
 {
     $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->getMock('\\Drupal\\Core\\Render\\AttachmentsResponseProcessorInterface');
     $subscriber = new AjaxResponseSubscriber($ajax_response_attachments_processor);
     $event = new FilterResponseEvent($this->getMock('\\Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST, $response);
     $subscriber->onResponse($event);
     $this->assertEquals('text/html; charset=utf-8', $response->headers->get('Content-Type'));
     $this->assertEquals($response->getContent(), '<textarea>[]</textarea>');
 }