Horde_Imap_Client test failure with latest PHP

Remi Collet <[email protected]>
Newsgroups gmane.comp.horde.devel
Message-ID <[email protected]>
Until 5.4.28 and 5.5.12, Test suite was OK.

Since 5.4.29 and 5.5.13 (and 5.6.0beta3) test fails.

1) Horde_Imap_Client_DateTimeTest::testDateTimeParsing with data set #0
('12 Sep 2007 15:49:12 UT', 1189612152)
Failed asserting that 0 matches expected 1189612152.

/dev/shm/BUILD/php-horde-Horde-Imap-Client-2.21.0/Horde_Imap_Client-2.21.0/test/Horde/Imap/Client/DateTimeTest.php:53

2) Horde_Imap_Client_DateTimeTest::testDateTimeParsing with data set #1
('Fri, 06 Oct 2006 12:15:13 +0100 (GMT+01:00)', 1160133313)
Failed asserting that 0 matches expected 1160133313.

/dev/shm/BUILD/php-horde-Horde-Imap-Client-2.21.0/Horde_Imap_Client-2.21.0/test/Horde/Imap/Client/DateTimeTest.php:53

Are you aware of this ?


From a quick look, it seems it is not (no more) possible to call a
second time the constructor, after a exception was raised.


The quick (and really dirty patch) fix this.
Probably a more clean solution is possible.


Regards,
Remi.

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
datetime.patch (text/x-patch, 1.1 KB)
diff -up Horde/Imap/Client/DateTime.php.old Horde/Imap/Client/DateTime.php
--- Horde/Imap/Client/DateTime.php.old	2014-06-04 19:55:57.639700231 +0200
+++ Horde/Imap/Client/DateTime.php	2014-06-04 19:56:42.986908638 +0200
@@ -31,6 +31,7 @@ class Horde_Imap_Client_DateTime extends
         $tz = new DateTimeZone('UTC');
 
         try {
+            new DateTime($time, $tz);
             parent::__construct($time, $tz);
             return;
         } catch (Exception $e) {}
@@ -38,6 +39,7 @@ class Horde_Imap_Client_DateTime extends
         /* Bug #5717 - Check for UT vs. UTC. */
         if (substr(rtrim($time), -3) === ' UT') {
             try {
+                new DateTime($tim . 'C', $tz);
                 parent::__construct($time . 'C', $tz);
                 return;
             } catch (Exception $e) {}
@@ -48,6 +50,7 @@ class Horde_Imap_Client_DateTime extends
         $date = preg_replace("/\s*\([^\)]+\)\s*$/", '', $time, -1, $i);
         if ($i) {
             try {
+                new DateTime($date, $tz);
                 parent::__construct($date, $tz);
                 return;
             } catch (Exception $e) {}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.