9820: Infinite loop in adoptAlarmTime (DST Boundary)
[tine20] / tests / tine20 / Calendar / Controller / EventNotificationsTests.php
index c7a7299..4d2a6bd 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2009-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
@@ -1010,6 +1010,39 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
     }
     
     /**
+     * testAdoptAlarmDSTBoundaryAllDayEvent
+     * 
+     * @see 0009820: Infinite loop in adoptAlarmTime / computeNextOccurrence (DST Boundary)
+     */
+    public function testAdoptAlarmDSTBoundaryAllDayEvent()
+    {
+        $event = $this->_getEvent();
+        $event->is_all_day_event = 1;
+        $event->dtstart = new Tinebase_DateTime('2014-03-03 23:00:00');
+        $event->dtend = new Tinebase_DateTime('2014-03-04 22:59:59');
+        $event->originator_tz = 'Europe/Berlin';
+        $event->rrule = 'FREQ=DAILY';
+        $event->alarms = new Tinebase_Record_RecordSet('Tinebase_Model_Alarm', array(
+            new Tinebase_Model_Alarm(array(
+                'minutes_before' => 15,
+            ), TRUE)
+        ));
+        
+        $savedEvent = Calendar_Controller_Event::getInstance()->create($event);
+        
+        $alarm = $savedEvent->alarms->getFirstRecord();
+        $alarm->sent_time = new Tinebase_DateTime('2014-03-29 22:46:01');
+        $alarm->alarm_time = new Tinebase_DateTime('2014-03-29 22:45:00');
+        $alarm->setOption('recurid', $savedEvent->uid . '-2014-03-29 23:00:00');
+        Tinebase_Alarm::getInstance()->update($alarm);
+        $alarm = $this->_eventController->get($savedEvent->getId())->alarms->getFirstRecord();
+        
+        Calendar_Controller_Event::getInstance()->adoptAlarmTime($savedEvent, $alarm, 'instance');
+        
+        $this->assertEquals('2014-03-30 21:45:00', $alarm->alarm_time->toString());
+    }
+    
+    /**
      * checks if mail for persona got send
      * 
      * @param string $_personas