setTimeZone(new DateTimeZone('UTC')); $this->assertFalse( $dt->isValid('bar'), 'Arbitrary strings must not be valid input' ); $this->assertFalse( $dt->isValid('13736a16223'), 'Invalid Unix timestamps must not be valid input' ); } public function testValidateValidInput() { $dt = new DateTimePicker('foo'); $dt->setTimeZone(new DateTimeZone('UTC')); $this->assertTrue( $dt->isValid('2013-07-12 08:03:43'), 'Using a valid date/time string must not fail' ); $this->assertTrue( $dt->isValid('@' . 1373616223), 'Using the Unix timestamp format must not fail' ); $this->assertTrue( $dt->isValid(1373616223), 'Using valid Unix timestamps must not fail' ); } public function testGetValueReturnsUnixTimestamp() { $dt = new DateTimePicker('foo'); $dt->setTimeZone(new DateTimeZone('UTC')) ->setValue('2013-07-12 08:03:43'); $this->assertEquals( $dt->getValue(), 1373616223, 'getValue did not return the correct Unix timestamp according to the given date/time ' . 'string' ); } public function testGetValueIsTimeZoneAware() { $dt = new DateTimePicker('foo'); $dt->setTimeZone(new DateTimeZone('Europe/Berlin')) ->setValue('2013-07-12 08:03:43'); $this->assertEquals( $dt->getValue(), 1373609023, 'getValue did not return the correct Unix timestamp according to the given date/time ' . 'string' ); } }