Mute Toggle with Reschedule, RecurException, StatusChange
authorsstamer <s.stamer@metaways.de>
Thu, 29 Jan 2015 15:04:07 +0000 (16:04 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 4 Feb 2015 12:30:21 +0000 (13:30 +0100)
+ Tests

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

index 24d746b..f82c120 100644 (file)
@@ -100,9 +100,9 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
     /**
      * Test event creation with muted invitation
      */
-    public function testMuteToogle()
+    public function testMuteToogleCreation()
     {
-        $event = $this->_getEvent(false, /* $mute = */ 1);
+        $event = $this->_getEvent(TRUE, /* $mute = */ 1);
         $event->attendee = $this->_getPersonaAttendee('jsmith, pwulf, sclever, jmcblack, rwright');
 
         self::flushMailer();
@@ -111,6 +111,44 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
 
         $this->assertEquals($event->mute, 1);
     }
+    
+    /**
+     * Test event reschedul with muted invitation
+     */
+    public function testMuteToogleReschedul()
+    {
+        $event = $this->_getEvent(TRUE, /* $mute = */ 1);
+        $event->attendee = $this->_getPersonaAttendee('jsmith, pwulf, sclever, jmcblack, rwright');
+        $persistentEvent = $this->_eventController->create($event);
+        
+        $persistentEvent->summary = 'reschedule notification has precedence over normal update';
+        $persistentEvent->dtstart->addHour(1);
+        $persistentEvent->dtend->addHour(1);
+        $persistentEvent->mute = 1;
+        $this->assertEquals($persistentEvent->mute, 1);
+        
+        self::flushMailer();
+        $updatedEvent = $this->_eventController->update($persistentEvent);
+        $this->_assertMail('jsmith, pwulf, sclever, jmcblack, rwright', NULL);
+    }
+    
+    /**
+     * testMuteToogleUpdateAttendeeStatus
+     */
+    public function testMuteToogleUpdateAttendeeStatus()
+    {
+        $event = $this->_getEvent(TRUE, /* $mute = */ 1);
+        $event->attendee = $this->_getPersonaAttendee('jsmith, pwulf, sclever, jmcblack, rwright');
+        $persistentEvent = $this->_eventController->create($event);
+    
+        $persistentEvent->attendee[1]->status = Calendar_Model_Attender::STATUS_DECLINED;
+        $persistentEvent->mute = 1;
+        $this->assertEquals($persistentEvent->mute, 1);
+    
+        self::flushMailer();
+        $updatedEvent = $this->_eventController->update($persistentEvent);
+        $this->_assertMail('jsmith, pwulf, sclever, jmcblack, rwright', NULL);
+    }
 
     /**
      * testInvitationWithAttachment
index f4d9b8e..1c2042a 100644 (file)
@@ -234,7 +234,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         }
         
         // send notifications
-        if ($this->_sendNotifications && $_record['mute'] != 1) {
+        if ($this->_sendNotifications && $_record->mute != 1) {
             $this->doSendNotifications($createdEvent, Tinebase_Core::getUser(), 'created');
         }        
 
@@ -555,7 +555,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         
         // send notifications
         $this->sendNotifications($sendNotifications);
-        if ($this->_sendNotifications) {
+        if ($this->_sendNotifications && $_record->mute != 1) {
             $this->doSendNotifications($updatedEvent, Tinebase_Core::getUser(), 'changed', $event);
         }
         return $updatedEvent;
@@ -614,6 +614,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                 if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
                     . ' ' . print_r($nextRegularRecurEvent->toArray(), TRUE));
                 
+                $nextRegularRecurEvent->mute = $exdate->mute;
                 $newBaseEvent = $this->createRecurException($nextRegularRecurEvent, FALSE, TRUE);
                 // @todo this should be done by createRecurException
                 $exdatesOfNewBaseEvent = $this->getRecurExceptions($newBaseEvent);
@@ -1154,7 +1155,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         $this->doContainerACLChecks($doContainerACLChecks);
         
         // send notifications
-        if ($this->_sendNotifications) {
+        if ($this->_sendNotifications && $_event->mute != 1) {
             // NOTE: recur exception is a fake event from client. 
             //       this might lead to problems, so we wrap the calls
             try {
@@ -1899,7 +1900,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         }
         
         // send notifications
-        if ($currentAttender->status != $updatedAttender->status && $this->_sendNotifications) {
+        if ($currentAttender->status != $updatedAttender->status && $this->_sendNotifications && $_event->mute != 1) {
             $updatedEvent = $this->get($event->getId());
             $this->doSendNotifications($updatedEvent, Tinebase_Core::getUser(), 'changed', $event);
         }