15
15
use Symfony \Component \HttpFoundation \Request ;
16
16
use Symfony \Component \HttpFoundation \Response ;
17
17
18
+ /**
19
+ * @group time-sensitive
20
+ */
18
21
class HttpCacheTest extends HttpCacheTestCase
19
22
{
20
23
public function testTerminateDelegatesTerminationOnlyForTerminableInterface ()
@@ -125,7 +128,7 @@ public function testDoesNotCacheRequestsWithACookieHeader()
125
128
126
129
public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified ()
127
130
{
128
- $ time = new \DateTime ( );
131
+ $ time = \DateTime:: createFromFormat ( ' U ' , time () );
129
132
130
133
$ this ->setNextResponse (200 , array ('Cache-Control ' => 'public ' , 'Last-Modified ' => $ time ->format (DATE_RFC2822 ), 'Content-Type ' => 'text/plain ' ), 'Hello World ' );
131
134
$ this ->request ('GET ' , '/ ' , array ('HTTP_IF_MODIFIED_SINCE ' => $ time ->format (DATE_RFC2822 )));
@@ -154,7 +157,7 @@ public function testRespondsWith304WhenIfNoneMatchMatchesETag()
154
157
155
158
public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch ()
156
159
{
157
- $ time = new \DateTime ( );
160
+ $ time = \DateTime:: createFromFormat ( ' U ' , time () );
158
161
159
162
$ this ->setNextResponse (200 , array (), '' , function ($ request , $ response ) use ($ time ) {
160
163
$ response ->setStatusCode (200 );
@@ -593,7 +596,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft
593
596
$ this ->assertTraceContains ('miss ' );
594
597
$ this ->assertTraceContains ('store ' );
595
598
$ this ->assertEquals ('Hello World ' , $ this ->response ->getContent ());
596
- $ this ->assertRegExp ('/s-maxage=(?:2|3) / ' , $ this ->response ->headers ->get ('Cache-Control ' ));
599
+ $ this ->assertRegExp ('/s-maxage=2 / ' , $ this ->response ->headers ->get ('Cache-Control ' ));
597
600
598
601
$ this ->request ('GET ' , '/ ' );
599
602
$ this ->assertHttpKernelIsNotCalled ();
@@ -607,8 +610,8 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft
607
610
$ values = $ this ->getMetaStorageValues ();
608
611
$ this ->assertCount (1 , $ values );
609
612
$ tmp = unserialize ($ values [0 ]);
610
- $ time = \DateTime::createFromFormat ('U ' , time ());
611
- $ tmp [0 ][1 ]['date ' ] = \DateTime:: createFromFormat ( ' U ' , time () - 5 ) ->format (DATE_RFC2822 );
613
+ $ time = \DateTime::createFromFormat ('U ' , time () - 5 );
614
+ $ tmp [0 ][1 ]['date ' ] = $ time ->format (DATE_RFC2822 );
612
615
$ r = new \ReflectionObject ($ this ->store );
613
616
$ m = $ r ->getMethod ('save ' );
614
617
$ m ->setAccessible (true );
@@ -657,8 +660,8 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft
657
660
$ values = $ this ->getMetaStorageValues ();
658
661
$ this ->assertCount (1 , $ values );
659
662
$ tmp = unserialize ($ values [0 ]);
660
- $ time = \DateTime::createFromFormat ('U ' , time ());
661
- $ tmp [0 ][1 ]['date ' ] = \DateTime:: createFromFormat ( ' U ' , time () - 5 ) ->format (DATE_RFC2822 );
663
+ $ time = \DateTime::createFromFormat ('U ' , time () - 5 );
664
+ $ tmp [0 ][1 ]['date ' ] = $ time ->format (DATE_RFC2822 );
662
665
$ r = new \ReflectionObject ($ this ->store );
663
666
$ m = $ r ->getMethod ('save ' );
664
667
$ m ->setAccessible (true );
@@ -1199,7 +1202,7 @@ public function testXForwarderForHeaderForPassRequests()
1199
1202
1200
1203
public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses ()
1201
1204
{
1202
- $ time = new \DateTime ( );
1205
+ $ time = \DateTime:: createFromFormat ( ' U ' , time () );
1203
1206
1204
1207
$ responses = array (
1205
1208
array (
0 commit comments