9578: Cli Ex / Import Calendar doesn't work
authorsstamer <s.stamer@metaways.de>
Tue, 4 Mar 2014 12:08:54 +0000 (13:08 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 13 Mar 2014 11:03:36 +0000 (12:03 +0100)
https://forge.tine20.org/mantisbt/view.php?id=9578
- Add test for Cli Export

Change-Id: I762f2a5a47b284744f08ee14675b9e73607298da
Reviewed-on: http://gerrit.tine20.com/customers/391
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Export/ICalTest.php
tests/tine20/Calendar/TestCase.php

index ea55ffa..fe73f31 100644 (file)
@@ -17,7 +17,7 @@ require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHe
 /**
  * Test class for Calendar_ICalTests
  */
-class Calendar_Export_ICalTest extends PHPUnit_Framework_TestCase //extends Calendar_TestCase
+class Calendar_Export_ICalTest extends Calendar_TestCase
 {
     public function setUp()
     {
@@ -35,6 +35,7 @@ class Calendar_Export_ICalTest extends PHPUnit_Framework_TestCase //extends Cale
             'priority'      => 1,
             'rrule'         => 'FREQ=DAILY;INTERVAL=1;UNTIL=2015-12-30 13:00:00'
         ));
+        parent::setUp();
     }
     
     public function testExport()
@@ -180,4 +181,26 @@ class Calendar_Export_ICalTest extends PHPUnit_Framework_TestCase //extends Cale
         // assert organizer
         $this->assertEquals(1, preg_match("/TRIGGER:-PT15M\r\n/", $ics), 'TRIGGER missing/broken');
     }
+    
+    /**
+     * test ical cli export
+     * 
+     */
+    public function testCliExport()
+    {
+        $eventData = $this->_getEvent(TRUE)->toArray();
+        $this->_uit = new Calendar_Frontend_Json();
+        $persistentEventData = $this->_uit->saveEvent($eventData);
+        
+        $this->_testNeedsTransaction();
+        $cmd = realpath(__DIR__ . "/../../../../tine20/tine20.php") . ' --method Calendar.exportICS ' .
+            $this->_testCalendar->getId() ;
+        
+        $cmd = TestServer::assembleCliCommand($cmd, TRUE);
+        exec($cmd, $output);
+        $result = implode(',', $output);
+        
+        $failMessage = print_r($output, TRUE);
+        $this->assertEquals(1, preg_match("/SUMMARY:{$eventData['summary']}/", $result), 'DESCRIPTION not correct');
+    }
 }
index ebef856..3260027 100644 (file)
@@ -104,18 +104,20 @@ abstract class Calendar_TestCase extends TestCase
         
         Calendar_Controller_Event::getInstance()->sendNotifications(false);
         
+        
         if (! $this->_transactionId) {
-            $events = $this->_backend->search(new Calendar_Model_EventFilter(array(
-                array('field' => 'container_id', 'operator' => 'in', 'value' => $this->_testCalendars->getId()),
-            )), new Tinebase_Model_Pagination(array()));
-            
-            // delete alarms
-            Tinebase_Alarm::getInstance()->deleteAlarmsOfRecord('Calendar_Model_Event', $events->getArrayOfIds());
-            
-            foreach ($events as $event) {
-                $this->_backend->delete($event->getId());
+            if ($this->_backend != NULL) {
+                $events = $this->_backend->search(new Calendar_Model_EventFilter(array(
+                    array('field' => 'container_id', 'operator' => 'in', 'value' => $this->_testCalendars->getId()),
+                )), new Tinebase_Model_Pagination(array()));
+                
+                // delete alarms
+                Tinebase_Alarm::getInstance()->deleteAlarmsOfRecord('Calendar_Model_Event', $events->getArrayOfIds());
+                
+                foreach ($events as $event) {
+                    $this->_backend->delete($event->getId());
+                }
             }
-            
             foreach ($this->_testCalendars as $cal) {
                 Tinebase_Container::getInstance()->deleteContainer($cal, true);
             }
@@ -125,6 +127,7 @@ abstract class Calendar_TestCase extends TestCase
             // reset test user
             Tinebase_Core::set(Tinebase_Core::USER, $this->_testUser);
         }
+        
     }
     
     /**