4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpFoundation\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Request;
17 abstract class ResponseTestCase extends TestCase
19 public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
21 // Check for HTTPS and IE 8
22 $request = new Request();
23 $request->server->set('HTTPS', true);
24 $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
26 $response = $this->provideResponse();
27 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
28 $response->prepare($request);
30 $this->assertFalse($response->headers->has('Cache-Control'));
32 // Check for IE 10 and HTTPS
33 $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)');
35 $response = $this->provideResponse();
36 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
37 $response->prepare($request);
39 $this->assertTrue($response->headers->has('Cache-Control'));
41 // Check for IE 9 and HTTPS
42 $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)');
44 $response = $this->provideResponse();
45 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
46 $response->prepare($request);
48 $this->assertTrue($response->headers->has('Cache-Control'));
50 // Check for IE 9 and HTTP
51 $request->server->set('HTTPS', false);
53 $response = $this->provideResponse();
54 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
55 $response->prepare($request);
57 $this->assertTrue($response->headers->has('Cache-Control'));
59 // Check for IE 8 and HTTP
60 $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
62 $response = $this->provideResponse();
63 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
64 $response->prepare($request);
66 $this->assertTrue($response->headers->has('Cache-Control'));
68 // Check for non-IE and HTTPS
69 $request->server->set('HTTPS', true);
70 $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');
72 $response = $this->provideResponse();
73 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
74 $response->prepare($request);
76 $this->assertTrue($response->headers->has('Cache-Control'));
78 // Check for non-IE and HTTP
79 $request->server->set('HTTPS', false);
81 $response = $this->provideResponse();
82 $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
83 $response->prepare($request);
85 $this->assertTrue($response->headers->has('Cache-Control'));
88 abstract protected function provideResponse();