Commit cecf7d0f authored by Markus Poerschke's avatar Markus Poerschke

Add test and clone dtEnd to avoid side effects

parent e3210f1e
......@@ -258,10 +258,11 @@ class Event extends Component
// An event can have a 'dtend' or 'duration', but not both.
if ($this->dtEnd !== null) {
$dtEnd = clone $this->dtEnd;
if ($this->noTime === true) {
$this->dtEnd = $this->dtEnd->add(new \DateInterval('P1D'));
$dtEnd = $dtEnd->add(new \DateInterval('P1D'));
}
$propertyBag->add(new DateTimeProperty('DTEND', $this->dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
$propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
} elseif ($this->duration !== null) {
$propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS'));
}
......
......@@ -119,4 +119,26 @@ class CalendarIntegrationTest extends TestCase
$this->assertRegExp($lines[$key], $line);
}
}
/**
* This test was introduced because of a regression bug.
*
* @see https://github.com/markuspoerschke/iCal/issues/98
*
* @coversNothing
*/
public function testRenderIsIdempotent()
{
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
$vEvent = new \Eluceo\iCal\Component\Event('123456');
$vEvent->setDtStart(new \DateTime('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-01-04'));
$vEvent->setNoTime(true);
$vEvent->setSummary('Vacations');
$vCalendar->addComponent($vEvent);
$this->assertEquals($vCalendar->render(), $vCalendar->render());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment