db backup prior to drupal security update
[yaffs-website] / vendor / symfony / http-kernel / Tests / HttpCache / ResponseCacheStrategyTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * This code is partially based on the Rack-Cache library by Ryan Tomayko,
9  * which is released under the MIT license.
10  * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
11  *
12  * For the full copyright and license information, please view the LICENSE
13  * file that was distributed with this source code.
14  */
15
16 namespace Symfony\Component\HttpKernel\Tests\HttpCache;
17
18 use PHPUnit\Framework\TestCase;
19 use Symfony\Component\HttpFoundation\Response;
20 use Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy;
21
22 class ResponseCacheStrategyTest extends TestCase
23 {
24     public function testMinimumSharedMaxAgeWins()
25     {
26         $cacheStrategy = new ResponseCacheStrategy();
27
28         $response1 = new Response();
29         $response1->setSharedMaxAge(60);
30         $cacheStrategy->add($response1);
31
32         $response2 = new Response();
33         $response2->setSharedMaxAge(3600);
34         $cacheStrategy->add($response2);
35
36         $response = new Response();
37         $response->setSharedMaxAge(86400);
38         $cacheStrategy->update($response);
39
40         $this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
41     }
42
43     public function testSharedMaxAgeNotSetIfNotSetInAnyEmbeddedRequest()
44     {
45         $cacheStrategy = new ResponseCacheStrategy();
46
47         $response1 = new Response();
48         $response1->setSharedMaxAge(60);
49         $cacheStrategy->add($response1);
50
51         $response2 = new Response();
52         $cacheStrategy->add($response2);
53
54         $response = new Response();
55         $response->setSharedMaxAge(86400);
56         $cacheStrategy->update($response);
57
58         $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
59     }
60
61     public function testSharedMaxAgeNotSetIfNotSetInMasterRequest()
62     {
63         $cacheStrategy = new ResponseCacheStrategy();
64
65         $response1 = new Response();
66         $response1->setSharedMaxAge(60);
67         $cacheStrategy->add($response1);
68
69         $response2 = new Response();
70         $response2->setSharedMaxAge(3600);
71         $cacheStrategy->add($response2);
72
73         $response = new Response();
74         $cacheStrategy->update($response);
75
76         $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
77     }
78 }