8000 harden test to not depend on the system's configured default timezone · symfony/http-kernel@9dfc68b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9dfc68b

Browse files
committed
harden test to not depend on the system's configured default timezone
1 parent fa321e0 commit 9dfc68b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Tests/HttpCache/ResponseCacheStrategyTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testMaxAgeUpdatedFromExpiresHeader()
102102
$cacheStrategy = new ResponseCacheStrategy();
103103

104104
$response1 = new Response();
105-
$response1->setExpires(new \DateTime('+ 1 hour'));
105+
$response1->setExpires(new \DateTime('+ 1 hour', new \DateTimeZone('UTC')));
106106
$response1->setPublic();
107107
$cacheStrategy->add($response1);
108108

@@ -112,15 +112,15 @@ public function testMaxAgeUpdatedFromExpiresHeader()
112112

113113
$this->assertSame('3600', $response->headers->getCacheControlDirective('max-age'));
114114
$this->assertNull($response->headers->getCacheControlDirective('s-maxage'));
115-
$this->assertSame((new \DateTime('+ 1 hour'))->format('D, d M Y H:i:s').' GMT', $response->headers->get('Expires'));
115+
$this->assertSame((new \DateTime('+ 1 hour', new \DateTimeZone('UTC')))->format('D, d M Y H:i:s').' GMT', $response->headers->get('Expires'));
116116
}
117117

118118
public function testMaxAgeAndSharedMaxAgeUpdatedFromExpiresHeader()
119119
{
120120
$cacheStrategy = new ResponseCacheStrategy();
121121

122122
$response1 = new Response();
123-
$response1->setExpires(new \DateTime('+ 1 day'));
123+
$response1->setExpires(new \DateTime('+ 1 day', new \DateTimeZone('UTC')));
124124
$response1->setPublic();
125125
$cacheStrategy->add($response1);
126126

@@ -131,7 +131,7 @@ public function testMaxAgeAndSharedMaxAgeUpdatedFromExpiresHeader()
131131

132132
$this->assertSame('3600', $response->headers->getCacheControlDirective('max-age'));
133133
$this->assertSame('86400', $response->headers->getCacheControlDirective('s-maxage'));
134-
$this->assertSame((new \DateTime('+ 1 hour'))->format('D, d M Y H:i:s').' GMT', $response->headers->get('Expires'));
134+
$this->assertSame((new \DateTime('+ 1 hour', new \DateTimeZone('UTC')))->format('D, d M Y H:i:s').' GMT', $response->headers->get('Expires'));
135135
}
136136

137137
public function testMainResponseNotCacheableWhenEmbeddedResponseRequiresValidation()

0 commit comments

Comments
 (0)
0