Skip to content
This repository

[ZF-12070] Fix remaining classes in Zend\Feed\Writer to accept UNIX timestamps which are <>10 digits #841

Merged
merged 1 commit into from about 2 years ago

2 participants

Adam Lundrigan Rob Allen
Adam Lundrigan

SVN sync r24641 r24642

Rob Allen akrabat merged commit 9765a23 into from February 25, 2012
Rob Allen akrabat closed this February 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 25, 2012
Adam Lundrigan [ZF-12070] Fix remaining classes in Zend\Feed\Writer to accept UNIX t…
…imestamps which are <>10 digits
9765a23
This page is out of date. Refresh to see the latest.
2  library/Zend/Feed/Writer/Deleted.php
@@ -131,7 +131,7 @@ public function setWhen($date = null)
131 131
         $zdate = null;
132 132
         if ($date === null) {
133 133
             $zdate = new Date\Date;
134  
-        } elseif (ctype_digit($date) && strlen($date) == 10) {
  134
+        } elseif (ctype_digit($date)) {
135 135
             $zdate = new Date\Date($date, Date\Date::TIMESTAMP);
136 136
         } elseif ($date instanceof Date\Date) {
137 137
             $zdate = $date;
4  library/Zend/Feed/Writer/Entry.php
@@ -197,7 +197,7 @@ public function setDateCreated($date = null)
197 197
         $zdate = null;
198 198
         if ($date === null) {
199 199
             $zdate = new Date\Date;
200  
-        } elseif (ctype_digit($date) && strlen($date) == 10) {
  200
+        } elseif (ctype_digit($date)) {
201 201
             $zdate = new Date\Date($date, Date\Date::TIMESTAMP);
202 202
         } elseif ($date instanceof Date\Date) {
203 203
             $zdate = $date;
@@ -217,7 +217,7 @@ public function setDateModified($date = null)
217 217
         $zdate = null;
218 218
         if ($date === null) {
219 219
             $zdate = new Date\Date;
220  
-        } elseif (ctype_digit($date) && strlen($date) == 10) {
  220
+        } elseif (ctype_digit($date)) {
221 221
             $zdate = new Date\Date($date, Date\Date::TIMESTAMP);
222 222
         } elseif ($date instanceof Date\Date) {
223 223
             $zdate = $date;
13  tests/Zend/Feed/Writer/DeletedTest.php
@@ -76,7 +76,18 @@ public function testSetWhenUsesGivenUnixTimestamp()
76 76
         $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
77 77
         $this->assertTrue($myDate->equals($entry->getWhen()));
78 78
     }
79  
-
  79
+ 
  80
+    /**
  81
+     * @group ZF-12070
  82
+     */
  83
+    public function testSetWhenUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
  84
+    {
  85
+        $entry = new Writer\Deleted;
  86
+        $entry->setWhen(123456789);
  87
+        $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
  88
+        $this->assertTrue($myDate->equals($entry->getWhen()));
  89
+    }
  90
+    
80 91
     public function testSetWhenUsesZendDateObject()
81 92
     {
82 93
         $entry = new Writer\Deleted;
22  tests/Zend/Feed/Writer/EntryTest.php
@@ -266,6 +266,17 @@ public function testSetDateCreatedUsesGivenUnixTimestamp()
266 266
         $this->assertTrue($myDate->equals($entry->getDateCreated()));
267 267
     }
268 268
 
  269
+    /**
  270
+     * @group ZF-12070
  271
+     */
  272
+    public function testSetDateCreatedUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
  273
+    {
  274
+        $entry = new Writer\Entry;
  275
+        $entry->setDateCreated(123456789);
  276
+        $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
  277
+        $this->assertTrue($myDate->equals($entry->getDateCreated()));
  278
+    }
  279
+    
269 280
     public function testSetDateCreatedUsesZendDateObject()
270 281
     {
271 282
         $entry = new Writer\Entry;
@@ -290,6 +301,17 @@ public function testSetDateModifiedUsesGivenUnixTimestamp()
290 301
         $this->assertTrue($myDate->equals($entry->getDateModified()));
291 302
     }
292 303
 
  304
+    /**
  305
+     * @group ZF-12070
  306
+     */
  307
+    public function testSetDateModifiedUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
  308
+    {
  309
+        $entry = new Writer\Entry;
  310
+        $entry->setDateModified(123456789);
  311
+        $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
  312
+        $this->assertTrue($myDate->equals($entry->getDateModified()));
  313
+    }
  314
+
293 315
     public function testSetDateModifiedUsesZendDateObject()
294 316
     {
295 317
         $entry = new Writer\Entry;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.