Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'adamlundrigan/hotfiz/ZF-12070'
Browse files Browse the repository at this point in the history
  • Loading branch information
akrabat committed Feb 25, 2012
2 parents bf56dde + 00fc5c4 commit dd490e0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Writer/Deleted.php
Expand Up @@ -131,7 +131,7 @@ public function setWhen($date = null)
$zdate = null;
if ($date === null) {
$zdate = new Date\Date;
} elseif (ctype_digit($date) && strlen($date) == 10) {
} elseif (ctype_digit($date)) {
$zdate = new Date\Date($date, Date\Date::TIMESTAMP);
} elseif ($date instanceof Date\Date) {
$zdate = $date;
Expand Down
4 changes: 2 additions & 2 deletions src/Writer/Entry.php
Expand Up @@ -197,7 +197,7 @@ public function setDateCreated($date = null)
$zdate = null;
if ($date === null) {
$zdate = new Date\Date;
} elseif (ctype_digit($date) && strlen($date) == 10) {
} elseif (ctype_digit($date)) {
$zdate = new Date\Date($date, Date\Date::TIMESTAMP);
} elseif ($date instanceof Date\Date) {
$zdate = $date;
Expand All @@ -217,7 +217,7 @@ public function setDateModified($date = null)
$zdate = null;
if ($date === null) {
$zdate = new Date\Date;
} elseif (ctype_digit($date) && strlen($date) == 10) {
} elseif (ctype_digit($date)) {
$zdate = new Date\Date($date, Date\Date::TIMESTAMP);
} elseif ($date instanceof Date\Date) {
$zdate = $date;
Expand Down
13 changes: 12 additions & 1 deletion test/Writer/DeletedTest.php
Expand Up @@ -76,7 +76,18 @@ public function testSetWhenUsesGivenUnixTimestamp()
$myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
$this->assertTrue($myDate->equals($entry->getWhen()));
}


/**
* @group ZF-12070
*/
public function testSetWhenUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
{
$entry = new Writer\Deleted;
$entry->setWhen(123456789);
$myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
$this->assertTrue($myDate->equals($entry->getWhen()));
}

public function testSetWhenUsesZendDateObject()
{
$entry = new Writer\Deleted;
Expand Down
22 changes: 22 additions & 0 deletions test/Writer/EntryTest.php
Expand Up @@ -266,6 +266,17 @@ public function testSetDateCreatedUsesGivenUnixTimestamp()
$this->assertTrue($myDate->equals($entry->getDateCreated()));
}

/**
* @group ZF-12070
*/
public function testSetDateCreatedUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
{
$entry = new Writer\Entry;
$entry->setDateCreated(123456789);
$myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
$this->assertTrue($myDate->equals($entry->getDateCreated()));
}

public function testSetDateCreatedUsesZendDateObject()
{
$entry = new Writer\Entry;
Expand All @@ -290,6 +301,17 @@ public function testSetDateModifiedUsesGivenUnixTimestamp()
$this->assertTrue($myDate->equals($entry->getDateModified()));
}

/**
* @group ZF-12070
*/
public function testSetDateModifiedUsesGivenUnixTimestampWhenItIsLessThanTenDigits()
{
$entry = new Writer\Entry;
$entry->setDateModified(123456789);
$myDate = new Date\Date('123456789', Date\Date::TIMESTAMP);
$this->assertTrue($myDate->equals($entry->getDateModified()));
}

public function testSetDateModifiedUsesZendDateObject()
{
$entry = new Writer\Entry;
Expand Down

0 comments on commit dd490e0

Please sign in to comment.