VCALENDAR converter: fixes empty CATEGORIES property
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 18 Aug 2014 12:23:02 +0000 (14:23 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:41 +0000 (11:26 +0200)
Change-Id: I58f2138fa1226f99b9e5d6ce9e16f370ce779a81
Reviewed-on: http://gerrit.tine20.com/customers/1008
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Convert/Event/VCalendar/GenericTest.php
tests/tine20/Calendar/Import/files/empty_categories.ics [new file with mode: 0644]
tine20/Tinebase/Model/Tag.php

index 4737488..bceb4e0 100644 (file)
@@ -647,13 +647,14 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
      * save ics test event
      * 
      * @param string $filename
+     * @param string $client
      * @return Calendar_Model_Event
      */
-    protected function _saveIcsEvent($filename)
+    protected function _saveIcsEvent($filename, $client = Calendar_Convert_Event_VCalendar_Factory::CLIENT_GENERIC)
     {
         $vcalendarStream = Calendar_Frontend_WebDAV_EventTest::getVCalendar(dirname(__FILE__) . '/../../../Import/files/' . $filename, 'r');
         
-        $this->_converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_GENERIC);
+        $this->_converter = Calendar_Convert_Event_VCalendar_Factory::factory($client);
         
         $event = $this->_converter->toTine20Model($vcalendarStream);
         
@@ -706,4 +707,14 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
         
         $this->assertContains('Mail an Frau LaLiLoLu ging am 4.11 raus, dass du später zur Ralf Sitzung kommst (joda)', $savedEvent->summary);
     }
+
+    /**
+     * testEmptyCategories
+     */
+    public function testEmptyCategories()
+    {
+        $savedEvent = $this->_saveIcsEvent('empty_categories.ics', Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX);
+        
+        $this->assertEquals('Flug nach Hamburg', $savedEvent->summary);
+    }
 }
diff --git a/tests/tine20/Calendar/Import/files/empty_categories.ics b/tests/tine20/Calendar/Import/files/empty_categories.ics
new file mode 100644 (file)
index 0000000..2e74c95
--- /dev/null
@@ -0,0 +1,19 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//Mac OS X 10.9.3//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+TRANSP:OPAQUE
+DTEND:20141018T201000Z
+PRIORITY:5
+UID:abcdefg@swiss.com
+LOCATION:Zurich
+DTSTAMP:20141018T184500Z
+DESCRIPTION:Alle angegebenen Zeiten sind Lokalzeiten am Abflugort
+SEQUENCE:0
+CLASS:PRIVATE
+CATEGORIES: 
+SUMMARY:Flug nach Hamburg
+DTSTART:20141018T184500Z
+END:VEVENT
+END:VCALENDAR
index c8f77c0..a7ace89 100644 (file)
@@ -114,6 +114,11 @@ class Tinebase_Model_Tag extends Tinebase_Record_Abstract
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) 
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to allocate tag ' . $tagName);
             
+            $tagName = trim($tagName);
+            if (empty($tagName)) {
+                continue;
+            }
+            
             $existingTags = Tinebase_Tags::getInstance()->searchTags(
                 new Tinebase_Model_TagFilter(array(
                     'name'        => $tagName,