0011050: VEVENT converter: fix timezone handling for all day events
[tine20] / tests / tine20 / Calendar / Convert / Event / VCalendar / MacOSXTest.php
index 5f4c0d6..bc34e77 100644 (file)
@@ -4,40 +4,23 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2011-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2011-2015 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Calendar_Convert_Event_VCalendar_MacOSX
  */
-class Calendar_Convert_Event_VCalendar_MacOSXTest extends PHPUnit_Framework_TestCase
+class Calendar_Convert_Event_VCalendar_MacOSXTest extends Calendar_TestCase
 {
     /**
      * @var array test objects
      */
     protected $objects = array();
-    
-    /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tine 2.0 Calendar WebDAV MacOSX Event Tests');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-    
+
     /**
      * testBackslashInDescription
-     * 
+     *
      * @see 0009176: iCal adds another backslash to description field
      */
     public function testBackslashInDescription()
@@ -52,12 +35,12 @@ class Calendar_Convert_Event_VCalendar_MacOSXTest extends PHPUnit_Framework_Test
             'uid' => Tinebase_Record_Abstract::generateUID(),
             'seq' => 1,
         ));
-        
+
         $converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX);
         $vevent = $converter->fromTine20Model($event)->serialize();
-        
+
         $convertedEvent = $converter->toTine20Model($vevent);
-        
+
         $this->assertEquals($event->description, $convertedEvent->description);
     }
 
@@ -77,9 +60,9 @@ class Calendar_Convert_Event_VCalendar_MacOSXTest extends PHPUnit_Framework_Test
         $this->assertNotEquals($event->organizer, $event->attendee[0]->user_id, 'organizer should not attend');
 
         // assert alarm
-        $this->assertEquals(1,$event->alarms->count(), 'there should be exactly one alarm');
+        $this->assertEquals(1, $event->alarms->count(), 'there should be exactly one alarm');
         $this->assertFalse((bool)$event->alarms->getFirstRecord()->getOption('custom'), 'alarm should be duration alarm');
-        $this->assertEquals(15, $event->alarms->getFirstRecord()->minutes_before, 'alarm shoud be 15 min. before');
+        $this->assertEquals(15, $event->alarms->getFirstRecord()->minutes_before, 'alarm should be 15 min. before');
         $this->assertEquals('2013-11-15 11:47:23', Calendar_Controller_Alarm::getAcknowledgeTime($event->alarms->getFirstRecord())->format(Tinebase_Record_Abstract::ISO8601LONG), 'ACKNOWLEDGED was not imported properly');
     }
 
@@ -108,4 +91,29 @@ class Calendar_Convert_Event_VCalendar_MacOSXTest extends PHPUnit_Framework_Test
         $event = $converter->toTine20Model($vcalendarStream);
         $this->assertEquals(Calendar_Model_Event::CLASS_PRIVATE, $event->class);
     }
+
+    /**
+     * testConvertAllDayEventWithExdate
+     *
+     * - exdate is the base event
+     */
+    public function testConvertAllDayEventWithExdate()
+    {
+        $converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX, '10.10.2');
+
+        $vcalendarStream = fopen(dirname(__FILE__) . '/../../../Import/files/apple_calendar_birthday.ics', 'r');
+        $updateEvent = $converter->toTine20Model($vcalendarStream);
+        $eventWithExdateOnBaseEvent = Calendar_Controller_MSEventFacade::getInstance()->create($updateEvent);
+
+        $this->assertEquals(1, count($eventWithExdateOnBaseEvent->exdate));
+
+        // refetch existing event here and pass it to converter
+        $eventWithExdateOnBaseEvent = Calendar_Controller_Event::getInstance()->get($eventWithExdateOnBaseEvent->getId());
+
+        $vcalendarStream2 = fopen(dirname(__FILE__) . '/../../../Import/files/apple_calendar_birthday2.ics', 'r');
+        $updateEvent2 = $converter->toTine20Model($vcalendarStream2, $eventWithExdateOnBaseEvent);
+
+        $this->assertEquals(1, count($updateEvent2->exdate), print_r($updateEvent2->toArray(), true));
+        $this->assertEquals('2015-04-27 21:59:59', $updateEvent2->rrule_until);
+    }
 }