Created
October 29, 2013 10:18
-
-
Save nojimage/7212052 to your computer and use it in GitHub Desktop.
timecop拡張を入れていると、WebTestCase経由のテストでResponse::setLastModifiedが使えない問題の対処 ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
if (!extension_loaded('timecop')) { | |
$response = $app->sendFile($file, 200, $headers); | |
} else { | |
// timecop hack | |
$response = new Symfony\Component\HttpFoundation\BinaryFileResponse($file, 200, $headers, false, null, false, false); | |
$date = \DateTime::createFromFormat('U', $response->getFile()->getMTime()); | |
$date->setTimezone(new \DateTimeZone('UTC')); | |
$response->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT'); | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment