From de01f5ae92e68b1bdc102069b58d404bbe92aa89 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 31 Oct 2014 14:32:02 -0400 Subject: [PATCH] Added tests. --- .../src/VuFindTest/Solr/UtilsTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php index 3fb051eebc7..364477564e7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php @@ -60,4 +60,32 @@ class UtilsTest extends \VuFindTest\Unit\TestCase $this->assertFalse(Utils::parseRange('1 TO 100')); $this->assertFalse(Utils::parseRange('[not a range to me]')); } + + /** + * Test sanitizeDate functionality. + * + * @return void + */ + public function testSanitizeDate() + { + $tests = array( + '[2014]' => '2014-01-01', + 'n.d.' => null, + 'may 7, 1981' => '1981-05-07', + 'July 1570' => '1570-07-01', + 'incomprehensible garbage' => null, + '1930/12/21' => '1930-12-21', + '1964?' => '1964-01-01', + '1947-3' => '1947-03-01', + '1973-02-31' => '1973-02-01', // illegal day + '1973-31-31' => '1973-01-01', // illegal month + ); + + foreach ($tests as $in => $out) { + $this->assertEquals( + $out === null ? null : $out . 'T00:00:00Z', // append standard time value unless null + Utils::sanitizeDate($in) + ); + } + } } \ No newline at end of file -- GitLab