Merge branch '2013.10' into 2014.11
[tine20] / tests / tine20 / Calendar / Frontend / ActiveSyncTest.php
@@ -2,18 +2,18 @@
 /**
  * Tine 2.0 - http://www.tine20.org
  * 
- * @package     ActiveSync
+ * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @copyright   Copyright (c) 2010-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
 /**
- * Test class for Calendar_Controller_Event
+ * Test class for Calendar_Frontend_ActiveSync
  * 
- * @package     ActiveSync
+ * @package     Calendar
  */
-class ActiveSync_Controller_CalendarTests extends ActiveSync_Controller_ControllerTest
+class Calendar_Frontend_ActiveSyncTest extends ActiveSync_Controller_ControllerTest
 {
     /**
      * name of the application
@@ -22,16 +22,10 @@ class ActiveSync_Controller_CalendarTests extends ActiveSync_Controller_Controll
      */
     protected $_applicationName = 'Calendar';
     
-    protected $_controllerName = 'ActiveSync_Controller_Calendar';
+    protected $_controllerName = 'Calendar_Frontend_ActiveSync';
     
     protected $_class = Syncroton_Data_Factory::CLASS_CALENDAR;
     
-    protected $_prefs;
-    
-    protected $_defaultCalendar;
-    
-    protected $_defaultHasChanged = false;
-    
     /**
      * @var array test objects
      */
@@ -57,7 +51,7 @@ class ActiveSync_Controller_CalendarTests extends ActiveSync_Controller_Controll
                             <Calendar:BusyStatus>2</Calendar:BusyStatus>
                             <Calendar:DtStamp>20121125T150537Z</Calendar:DtStamp>
                             <Calendar:EndTime>20121123T160000Z</Calendar:EndTime>
-                            <Calendar:Sensitivity>0</Calendar:Sensitivity>
+                            <Calendar:Sensitivity>2</Calendar:Sensitivity>
                             <Calendar:Subject>Repeat</Calendar:Subject>
                             <Calendar:StartTime>20121123T130000Z</Calendar:StartTime>
                             <Calendar:UID>6de7cb687964dc6eea109cd81750177979362217</Calendar:UID>
@@ -509,6 +503,8 @@ Zeile 3</AirSyncBase:Data>
     {
         parent::setUp();
         
+        Calendar_Controller_Event::getInstance()->doContainerACLChecks(true);
+        
         // replace email to make current user organizer and attendee
         $testConfig = Zend_Registry::get('testConfig');
         $email = ($testConfig->email) ? $testConfig->email : Tinebase_Core::getUser()->accountEmailAddress;
@@ -517,18 +513,6 @@ Zeile 3</AirSyncBase:Data>
             'lars@kneschke.de',
             'unittest@tine20.org',
         ), $email, $this->_testXMLInput);
-        
-        $this->_prefs = $prefs = new Calendar_Preference();
-        $this->_defaultCalendar = Tinebase_Core::getPreference('Calendar')->{Calendar_Preference::DEFAULTCALENDAR};
-    }
-    
-    protected  function tearDown()
-    {
-        parent::tearDown();
-        
-        if ($this->_defaultHasChanged) {
-            $this->_prefs->setValue(Calendar_Preference::DEFAULTCALENDAR, $this->_defaultCalendar);
-        }
     }
     
     /**
@@ -557,6 +541,7 @@ Zeile 3</AirSyncBase:Data>
         $this->assertEquals(2,         $syncrotonEvent->busyStatus);
         $this->assertEquals('Repeat',  $syncrotonEvent->subject);
         $this->assertEquals(15,        $syncrotonEvent->reminder);
+        $this->assertEquals(2,         $syncrotonEvent->sensitivity);
         $this->assertTrue($syncrotonEvent->endTime instanceof DateTime);
         $this->assertTrue($syncrotonEvent->startTime instanceof DateTime);
         $this->assertEquals($thisYear . '1123T160000Z', $syncrotonEvent->endTime->format('Ymd\THis\Z'));
@@ -634,6 +619,7 @@ Zeile 3</AirSyncBase:Data>
         #echo '----------------' . PHP_EOL; foreach ($syncrotonEvent as $key => $value) {echo "$key => "; var_dump($value);}
         
         $this->assertEquals(0, $syncrotonEvent->allDayEvent);
+        $this->assertEquals(0, $syncrotonEvent->sensitivity);
         $this->assertTrue($syncrotonEvent->endTime instanceof DateTime);
         $this->assertTrue($syncrotonEvent->startTime instanceof DateTime);
         $this->assertEquals('20101220T100000Z', $syncrotonEvent->endTime->format('Ymd\THis\Z'));
@@ -835,7 +821,7 @@ Zeile 3</AirSyncBase:Data>
         list($serverId, $syncrotonEvent) = $this->testCreateEntry($syncrotonFolder);
         
         // transfer event to other user
-        $rwright = array_value('rwright', $this->_personas = Zend_Registry::get('personas'));
+        $rwright = Tinebase_Helper::array_value('rwright', $this->_personas = Zend_Registry::get('personas'));
         $eventBackend = new Calendar_Backend_Sql();
         $eventBackend->updateMultiple($eventBackend->getMultipleByProperty($syncrotonEvent->uID, 'uid')->id, array(
             'container_id'  => Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $rwright->getId()),
@@ -1027,7 +1013,7 @@ Zeile 3</AirSyncBase:Data>
     
         $folderA = $this->testCreateFolder(); // personal of test user
         
-        $sclever = array_value('sclever', Zend_Registry::get('personas'));
+        $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
         $folderB = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $sclever->getId());
 
         // have syncGerant for sclever
@@ -1203,8 +1189,7 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMA
         $syncrotonFolder2 = $this->testCreateFolder();
         
         //make $syncrotonFolder2 the default
-        $this->_prefs->setValue(Calendar_Preference::DEFAULTCALENDAR, $syncrotonFolder2->serverId);
-        $this->_defaultHasChanged = true;
+        Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $syncrotonFolder2->serverId);
         
         $controller = Syncroton_Data_Factory::factory($this->_class, $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE), Tinebase_DateTime::now());
         
@@ -1240,6 +1225,11 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMA
     {
         // create event
         $syncrotonFolder = $this->testCreateFolder();
+        $syncrotonFolder2 = $this->testCreateFolder();
+        
+        //make $syncrotonFolder2 the default
+        Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $syncrotonFolder2->serverId);
+        
         $controller = Syncroton_Data_Factory::factory($this->_class, $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE), Tinebase_DateTime::now());
         list($serverId, $syncrotonEvent) = $this->testCreateEntry($syncrotonFolder);