Open Journal Systems  3.3.0
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 
13 
14 use PHPUnit\Framework\TestCase;
16 
17 abstract class ResponseTestCase extends TestCase
18 {
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 }
Symfony\Component\HttpFoundation\Tests\ResponseTestCase\testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE
testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
Definition: ResponseTestCase.php:19
Symfony\Component\HttpFoundation\Request
Definition: lib/vendor/symfony/http-foundation/Request.php:31
Symfony\Component\HttpFoundation\Tests\ResponseTestCase
Definition: ResponseTestCase.php:17
Symfony\Component\HttpFoundation\Tests
Definition: AcceptHeaderItemTest.php:12
Symfony\Component\HttpFoundation\Tests\ResponseTestCase\provideResponse
provideResponse()