$response =
new Response('', 200,
['ETag' => '"12345"'
]);
$this->
assertTrue($response->
isValidateable(), '->isValidateable() returns true if ETag is present'
);
$response =
new Response();
$this->
assertFalse($response->
isValidateable(), '->isValidateable() returns false when no validator is present'
);
} public function testGetDate() { $oneHourAgo =
$this->
createDateTimeOneHourAgo();
$response =
new Response('', 200,
['Date' =>
$oneHourAgo->
format(\DATE_RFC2822
)]);
$date =
$response->
getDate();
$this->
assertEquals($oneHourAgo->
getTimestamp(),
$date->
getTimestamp(), '->getDate() returns the Date header if present'
);
$response =
new Response();
$date =
$response->
getDate();
$this->
assertEquals(time(),
$date->
getTimestamp(), '->getDate() returns the current Date if no Date header present'
);
$response =
new Response('', 200,
['Date' =>
$this->
createDateTimeOneHourAgo()->
format(\DATE_RFC2822
)]);
$now =
$this->
createDateTimeNow();
$response->headers->
set('Date',
$now->
format(\DATE_RFC2822
));
$date =
$response->
getDate();
$this->
assertEquals($now->
getTimestamp(),
$date->
getTimestamp(), '->getDate() returns the date when the header has been modified'
);