Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hotfix for #5912: wrong datetime select form element cloning logic #5913

Closed
wants to merge 2 commits into from

1 participant

Marco Pivetta
This page is out of date. Refresh to see the latest.
2  library/Zend/Form/Element/DateTimeSelect.php
View
@@ -319,7 +319,7 @@ public function __clone()
$this->dayElement = clone $this->dayElement;
$this->monthElement = clone $this->monthElement;
$this->yearElement = clone $this->yearElement;
- $this->hourElement = clone $this->monthElement;
+ $this->hourElement = clone $this->hourElement;
$this->minuteElement = clone $this->minuteElement;
$this->secondElement = clone $this->secondElement;
}
15 tests/ZendTest/Form/Element/DateTimeSelectTest.php
View
@@ -114,4 +114,19 @@ public function testUseDefaultValueForSecondsIfNotProvided()
$this->assertEquals('04', $element->getMinuteElement()->getValue());
$this->assertEquals('00', $element->getSecondElement()->getValue());
}
+
+ public function testCloningPreservesCorrectValues()
+ {
+ $element = new DateTimeSelectElement();
+ $element->setValue(new DateTime('2014-01-02 03:04:05'));
+
+ $cloned = clone $element;
+
+ $this->assertEquals('2014', $cloned->getYearElement()->getValue());
+ $this->assertEquals('01', $cloned->getMonthElement()->getValue());
+ $this->assertEquals('02', $cloned->getDayElement()->getValue());
+ $this->assertEquals('03', $cloned->getHourElement()->getValue());
+ $this->assertEquals('04', $cloned->getMinuteElement()->getValue());
+ $this->assertEquals('05', $cloned->getSecondElement()->getValue());
+ }
}
Something went wrong with that request. Please try again.