The given date must either be an RFC2822 parseable date string or a DateTime
object. The timezone will be converted to GMT internally, but the point in
time remains the same.
public setLastModified ( string | DateTime $date ) : |
||
$date | string | DateTime | |
return | This response, for method chaining |
/** * RFC 2616 / 14.25 (If-Modified-Since) * * @test */ public function makeStandardsCompliantReturns304ResponseIfResourceWasNotModified() { $modifiedSince = \DateTime::createFromFormat(DATE_RFC2822, 'Sun, 20 May 2012 12:00:00 GMT'); $lastModified = \DateTime::createFromFormat(DATE_RFC2822, 'Fr, 18 May 2012 12:00:00 GMT'); $request = Request::create(new Uri('http://localhost')); $response = new Response(); $request->setHeader('If-Modified-Since', $modifiedSince); $response->setLastModified($lastModified); $response->setContent('Some Content'); $response->makeStandardsCompliant($request); $this->assertSame(304, $response->getStatusCode()); $this->assertSame('', $response->getContent()); }