fixes compareCalendars: filter summary matching subset
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 17 Nov 2014 21:00:04 +0000 (22:00 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 18 Nov 2014 13:50:30 +0000 (14:50 +0100)
and adds a test for all day events

Change-Id: I0edf45625c25eb5a27380c105dbc2e6eb36edb16
Reviewed-on: http://gerrit.tine20.com/customers/1361
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Controller/EventTests.php
tine20/Calendar/Controller/Event.php

index aafa94b..3b6e2cb 100644 (file)
@@ -1391,7 +1391,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
         $until = Tinebase_DateTime::now()->addWeek(2);
         $result = Calendar_Controller_Event::getInstance()->compareCalendars($cal1->getId(), $cal2->getId(), $from, $until);
         
-        $this->assertEquals(1, count($result['matching']), 'event3 + 4 should have matched: ' . print_r($result['matching']->toArray(), true));
+        $this->assertEquals(2, count($result['matching']), 'events 3+4 / 8+9 should have matched: ' . print_r($result['matching']->toArray(), true));
         $this->assertEquals(1, count($result['changed']), 'event 5 should appear in changed: ' . print_r($result['changed']->toArray(), true));
         $this->assertEquals(1, count($result['missingInCal1']), 'event 2 should miss from cal1: ' . print_r($result['missingInCal1']->toArray(), true));
         $this->assertEquals(1, count($result['missingInCal2']), 'event 6 should miss from cal2 ' . print_r($result['missingInCal2']->toArray(), true));
@@ -1406,6 +1406,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
      * - event5: slightly different from event1 (same summary) / in cal2
      * - event6: only in cal1 (next week)
      * - event7: only in displaycontainer
+     * - event8+9: in both calendars (whole day)
      * 
      * @param Tinebase_Model_Container $cal1
      * @param Tinebase_Model_Container $cal2
@@ -1464,6 +1465,15 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
         $this->_controller->create($event7);
         Tinebase_Core::set(Tinebase_Core::USER, $this->_originalTestUser);
         Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $currentDefault);
+        
+        $event8 = $this->_getEvent(true);
+        $event8->summary = 'event 8';
+        $event8->is_all_day_event = true;
+        $event9 = clone $event8;
+        $this->_controller->create($event8);
+        
+        $event9->container_id = $cal2->getId();
+        $this->_controller->create($event9);
     }
     
     public function testRepairAttendee()
index 97abdc3..9504830 100644 (file)
@@ -2278,7 +2278,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                         . " Found " . count($summaryMatch) . ' events with matching summaries');
                     
-                    $dtStartMatch = $cal2Events->filter('dtstart', $event->dtstart);
+                    $dtStartMatch = $summaryMatch->filter('dtstart', $event->dtstart);
                     if (count($dtStartMatch) > 0) {
                         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                             . " Found " . count($summaryMatch) . ' events with matching dtstarts and summaries');