diff options
author | Andreas Gohr <andi@splitbrain.org> | 2010-06-09 21:43:10 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2010-06-09 21:43:10 +0200 |
commit | 5ab78106b0f9170d5e4930d0901862e4373a686f (patch) | |
tree | 1bf04d874dd0afd853c33bb70c0178d3b9697d5b /_test | |
parent | ccee78424602b02309b2c81b3fa932bbcce1a03b (diff) | |
download | rpg-5ab78106b0f9170d5e4930d0901862e4373a686f.tar.gz rpg-5ab78106b0f9170d5e4930d0901862e4373a686f.tar.bz2 |
Make XMLRPC date parsing more flexible FS#1966
Since the specs aren't 100% clear, dates might be passed in different
formats by various XMLRPC clients. This patch makes date parsing a bit
more flexible.
Unit tests included.
Diffstat (limited to '_test')
-rw-r--r-- | _test/cases/inc/IXR_Library_date.test.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/_test/cases/inc/IXR_Library_date.test.php b/_test/cases/inc/IXR_Library_date.test.php new file mode 100644 index 000000000..a2b6154d8 --- /dev/null +++ b/_test/cases/inc/IXR_Library_date.test.php @@ -0,0 +1,34 @@ +<?php +require_once DOKU_INC.'inc/IXR_Library.php'; + +class ixr_library_date_test extends UnitTestCase { + + + function test_parseIso(){ + // multiple tests + $tests = array( + // full datetime, different formats + array('2010-08-17T09:23:14', 1282036994), + array('20100817T09:23:14', 1282036994), + array('2010-08-17 09:23:14', 1282036994), + array('20100817 09:23:14', 1282036994), + array('2010-08-17T09:23:14Z', 1282036994), + array('20100817T09:23:14Z', 1282036994), + + // no seconds + array('2010-08-17T09:23', 1282036980), + array('20100817T09:23', 1282036980), + + // no time + array('2010-08-17', 1282003200), + //array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp + ); + + foreach($tests as $test){ + $dt = new IXR_Date($test[0]); + $this->assertEqual($dt->getTimeStamp(),$test[1]); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : |