function testPipePriorFilter() { $pipe = new T_Validate_UnixDate('d|m|y'); $filter = new T_Filter_DateStr(DATE_ATOM, $pipe); $time = $pipe->transform('17/02/2002'); $expected = date(DATE_ATOM, $time); $this->assertSame($filter->transform('17/02/2002'), $expected); }
function testLastModifiedHeaderContainsCorrectDate() { $lm = 1188994102; $filter = new T_Response_ConditionalGet($lm, $this->getEnvironment()); $response = new T_Test_ResponseStub(); $filter->preFilter($response); $headers = $response->getHeaders(); $as_unix = new T_Validate_UnixDate(); $header_lm = $as_unix->transform($headers['Last-Modified']); $this->assertSame($header_lm, $lm); }
/** * Test expiry time is in future */ function testCacheExpiresAfterSpecifiedDuration() { $filter = new T_Response_ClientCache(60 * 60); $response = new T_Test_ResponseStub(); $now = time(); $filter->preFilter($response); $headers = $response->getHeaders(); $as_time = new T_Validate_UnixDate(); $expires = $as_time->transform($headers['Expires']); $this->assertTrue(abs($expires - $now - 60 * 60) <= 2); // (allow 2 second out to allow for code execution) }
function testPipePriorFilter() { $pipe = new T_Validate_UnixDate('d|m|y'); $filter = new T_Validate_WithinDateRange('d-m-Y', 24 * 60 * 60, 2 * 24 * 60 * 60, $pipe); $this->assertSame($filter->transform('02/01/1970'), $pipe->transform('02/01/1970')); }
function testDateThatMatchesFormatButIsInvalid() { $invalid = array('d|m|y' => '17/2/-123', 'd|m|y' => '123/2/2002', 'd|m|y' => '31/2/2003', 'd|m|y' => '15/13/2002', 'm|y' => '13/2002', 'm|y' => '5/-123'); foreach ($invalid as $fmt => $date) { try { $filter = new T_Validate_UnixDate($fmt); $filter->transform($date); $this->fail(); } catch (T_Exception_Filter $e) { } } }