| 3 |
liveuser |
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 Symfony\Component\HttpFoundation\Request;
|
|
|
15 |
|
|
|
16 |
abstract class ResponseTestCase extends \PHPUnit_Framework_TestCase
|
|
|
17 |
{
|
|
|
18 |
public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
|
|
|
19 |
{
|
|
|
20 |
// Check for HTTPS and IE 8
|
|
|
21 |
$request = new Request();
|
|
|
22 |
$request->server->set('HTTPS', true);
|
|
|
23 |
$request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
|
|
|
24 |
|
|
|
25 |
$response = $this->provideResponse();
|
|
|
26 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
27 |
$response->prepare($request);
|
|
|
28 |
|
|
|
29 |
$this->assertFalse($response->headers->has('Cache-Control'));
|
|
|
30 |
|
|
|
31 |
// Check for IE 10 and HTTPS
|
|
|
32 |
$request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)');
|
|
|
33 |
|
|
|
34 |
$response = $this->provideResponse();
|
|
|
35 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
36 |
$response->prepare($request);
|
|
|
37 |
|
|
|
38 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
39 |
|
|
|
40 |
// Check for IE 9 and HTTPS
|
|
|
41 |
$request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)');
|
|
|
42 |
|
|
|
43 |
$response = $this->provideResponse();
|
|
|
44 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
45 |
$response->prepare($request);
|
|
|
46 |
|
|
|
47 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
48 |
|
|
|
49 |
// Check for IE 9 and HTTP
|
|
|
50 |
$request->server->set('HTTPS', false);
|
|
|
51 |
|
|
|
52 |
$response = $this->provideResponse();
|
|
|
53 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
54 |
$response->prepare($request);
|
|
|
55 |
|
|
|
56 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
57 |
|
|
|
58 |
// Check for IE 8 and HTTP
|
|
|
59 |
$request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
|
|
|
60 |
|
|
|
61 |
$response = $this->provideResponse();
|
|
|
62 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
63 |
$response->prepare($request);
|
|
|
64 |
|
|
|
65 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
66 |
|
|
|
67 |
// Check for non-IE and HTTPS
|
|
|
68 |
$request->server->set('HTTPS', true);
|
|
|
69 |
$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');
|
|
|
70 |
|
|
|
71 |
$response = $this->provideResponse();
|
|
|
72 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
73 |
$response->prepare($request);
|
|
|
74 |
|
|
|
75 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
76 |
|
|
|
77 |
// Check for non-IE and HTTP
|
|
|
78 |
$request->server->set('HTTPS', false);
|
|
|
79 |
|
|
|
80 |
$response = $this->provideResponse();
|
|
|
81 |
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
|
|
|
82 |
$response->prepare($request);
|
|
|
83 |
|
|
|
84 |
$this->assertTrue($response->headers->has('Cache-Control'));
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
abstract protected function provideResponse();
|
|
|
88 |
}
|