Merge branch 'pu/2013.03/modelconfig-hr'
[tine20] / tests / tine20 / Calendar / JsonTests.php
index 6a30ae7..c6c186b 100644 (file)
@@ -221,6 +221,8 @@ class Calendar_JsonTests extends Calendar_TestCase
         
         $filter = $this->_getEventFilterArray();
         $searchResultData = $this->_uit->searchEvents($filter, array());
+        
+        $this->assertTrue(! empty($searchResultData['results']));
         $resultEventData = $searchResultData['results'][0];
         
         $this->_assertJsonEvent($eventData, $resultEventData, 'failed to search event');
@@ -299,6 +301,7 @@ class Calendar_JsonTests extends Calendar_TestCase
         $filter[] = array('field' => 'organizer', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT);
         
         $searchResultData = $this->_uit->searchEvents($filter, array());
+        $this->assertTrue(! empty($searchResultData['results']));
         $resultEventData = $searchResultData['results'][0];
         $this->_assertJsonEvent($eventData, $resultEventData, 'failed to search event');
         
@@ -310,7 +313,6 @@ class Calendar_JsonTests extends Calendar_TestCase
     
     /**
      * search event with alarm
-     *
      */
     public function testSearchEventsWithAlarm()
     {
@@ -318,6 +320,7 @@ class Calendar_JsonTests extends Calendar_TestCase
         $persistentEventData = $this->_uit->saveEvent($eventData);
         
         $searchResultData = $this->_uit->searchEvents($this->_getEventFilterArray(), array());
+        $this->assertTrue(! empty($searchResultData['results']));
         $resultEventData = $searchResultData['results'][0];
         
         $this->_assertJsonEvent($persistentEventData, $resultEventData, 'failed to search event with alarm');
@@ -649,6 +652,7 @@ class Calendar_JsonTests extends Calendar_TestCase
         ));
         
         $searchResultData = $this->_uit->searchEvents($filter, array());
+        $this->assertTrue(! empty($searchResultData['results']));
         $resultEventData = $searchResultData['results'][0];
         
         $this->_assertJsonEvent($eventData, $resultEventData, 'failed to filter for me as attender');
@@ -725,7 +729,8 @@ class Calendar_JsonTests extends Calendar_TestCase
             'summary' => 'bla bla',
             'class'    => 'PUBLIC',
             'transp'    => 'OPAQUE',
-            'container_id' => $container['id']
+            'container_id' => $container['id'],
+            'organizer' => Tinebase_Core::getUser()->contact_id
             ));
         $event = Calendar_Controller_Event::getInstance()->create($event);
         $this->assertEquals($container['id'], $event->container_id);
@@ -1310,6 +1315,30 @@ class Calendar_JsonTests extends Calendar_TestCase
             $this->assertEquals(Calendar_Model_Attender::STATUS_TENTATIVE, $attender['status'], 'both attendee status should be TENTATIVE: ' . print_r($attender, TRUE));
         }
     }
+
+    /**
+     * testFreeBusyCheckForExdates
+     * 
+     * @see 0008464: freebusy check does not work when creating recur exception
+     */
+    public function testFreeBusyCheckForExdates()
+    {
+        $events = $this->testCreateRecurException();
+        $exception = $this->_getException($events, 1);
+        
+        $anotherEvent = $this->_getEvent(TRUE);
+        $anotherEvent = $this->_uit->saveEvent($anotherEvent->toArray());
+        
+        $exception['dtstart'] = $anotherEvent['dtstart'];
+        $exception['dtend'] = $anotherEvent['dtend'];
+        
+        try {
+            $event = $this->_uit->saveEvent($exception, TRUE);
+            $this->fail('Calendar_Exception_AttendeeBusy expected when saving exception: ' . print_r($exception, TRUE));
+        } catch (Calendar_Exception_AttendeeBusy $ceab) {
+            $this->assertEquals('Calendar_Exception_AttendeeBusy', get_class($ceab));
+        }
+    }
     
     /**
      * testAddAttachmentToRecurSeries