From 9186ab95943b7c2467a0f27f30bed9db3c589b9d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 27 Jun 2015 14:57:44 +0200 Subject: LinkDB::filterDay(): check input date format Signed-off-by: VirtualTam --- tests/UtilsTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/UtilsTest.php') diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index bbba99f2..90392dfb 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -74,5 +74,24 @@ class UtilsTest extends PHPUnit_Framework_TestCase $this->assertTrue(endsWith('å!ùµ', 'ùµ', false)); $this->assertTrue(endsWith('µ$åù', 'åù', true)); } + + /** + * Check valid date strings, according to a DateTime format + */ + public function testCheckValidDateFormat() + { + $this->assertTrue(checkDateFormat('Ymd', '20150627')); + $this->assertTrue(checkDateFormat('Y-m-d', '2015-06-27')); + } + + /** + * Check erroneous date strings, according to a DateTime format + */ + public function testCheckInvalidDateFormat() + { + $this->assertFalse(checkDateFormat('Ymd', '2015')); + $this->assertFalse(checkDateFormat('Y-m-d', '2015-06')); + $this->assertFalse(checkDateFormat('Ymd', 'DeLorean')); + } } ?> -- cgit v1.2.3