Yaffs site version 1.1
[yaffs-website] / vendor / symfony / http-foundation / Tests / ResponseTestCase.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpFoundation\Tests;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Request;
16
17 abstract class ResponseTestCase extends TestCase
18 {
19     public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
20     {
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)');
25
26         $response = $this->provideResponse();
27         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
28         $response->prepare($request);
29
30         $this->assertFalse($response->headers->has('Cache-Control'));
31
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)');
34
35         $response = $this->provideResponse();
36         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
37         $response->prepare($request);
38
39         $this->assertTrue($response->headers->has('Cache-Control'));
40
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)');
43
44         $response = $this->provideResponse();
45         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
46         $response->prepare($request);
47
48         $this->assertTrue($response->headers->has('Cache-Control'));
49
50         // Check for IE 9 and HTTP
51         $request->server->set('HTTPS', false);
52
53         $response = $this->provideResponse();
54         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
55         $response->prepare($request);
56
57         $this->assertTrue($response->headers->has('Cache-Control'));
58
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)');
61
62         $response = $this->provideResponse();
63         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
64         $response->prepare($request);
65
66         $this->assertTrue($response->headers->has('Cache-Control'));
67
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');
71
72         $response = $this->provideResponse();
73         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
74         $response->prepare($request);
75
76         $this->assertTrue($response->headers->has('Cache-Control'));
77
78         // Check for non-IE and HTTP
79         $request->server->set('HTTPS', false);
80
81         $response = $this->provideResponse();
82         $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
83         $response->prepare($request);
84
85         $this->assertTrue($response->headers->has('Cache-Control'));
86     }
87
88     abstract protected function provideResponse();
89 }