ResponseTestCase.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Tests;
  11. use Symfony\Component\HttpFoundation\Request;
  12. abstract class ResponseTestCase extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
  15. {
  16. // Check for HTTPS and IE 8
  17. $request = new Request();
  18. $request->server->set('HTTPS', true);
  19. $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
  20. $response = $this->provideResponse();
  21. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  22. $response->prepare($request);
  23. $this->assertFalse($response->headers->has('Cache-Control'));
  24. // Check for IE 10 and HTTPS
  25. $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)');
  26. $response = $this->provideResponse();
  27. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  28. $response->prepare($request);
  29. $this->assertTrue($response->headers->has('Cache-Control'));
  30. // Check for IE 9 and HTTPS
  31. $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)');
  32. $response = $this->provideResponse();
  33. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  34. $response->prepare($request);
  35. $this->assertTrue($response->headers->has('Cache-Control'));
  36. // Check for IE 9 and HTTP
  37. $request->server->set('HTTPS', false);
  38. $response = $this->provideResponse();
  39. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  40. $response->prepare($request);
  41. $this->assertTrue($response->headers->has('Cache-Control'));
  42. // Check for IE 8 and HTTP
  43. $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
  44. $response = $this->provideResponse();
  45. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  46. $response->prepare($request);
  47. $this->assertTrue($response->headers->has('Cache-Control'));
  48. // Check for non-IE and HTTPS
  49. $request->server->set('HTTPS', true);
  50. $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17');
  51. $response = $this->provideResponse();
  52. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  53. $response->prepare($request);
  54. $this->assertTrue($response->headers->has('Cache-Control'));
  55. // Check for non-IE and HTTP
  56. $request->server->set('HTTPS', false);
  57. $response = $this->provideResponse();
  58. $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
  59. $response->prepare($request);
  60. $this->assertTrue($response->headers->has('Cache-Control'));
  61. }
  62. abstract protected function provideResponse();
  63. }