9728: Calendar Cli exportICS fails with empty calendar
authorsstamer <s.stamer@metaways.de>
Mon, 17 Mar 2014 10:07:48 +0000 (11:07 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 20 Mar 2014 21:44:56 +0000 (22:44 +0100)
https://forge.tine20.org/mantisbt/view.php?id=9728
- Always fails if there are no records
- Unittest

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

index fe73f31..4189f03 100644 (file)
@@ -203,4 +203,19 @@ class Calendar_Export_ICalTest extends Calendar_TestCase
         $failMessage = print_r($output, TRUE);
         $this->assertEquals(1, preg_match("/SUMMARY:{$eventData['summary']}/", $result), 'DESCRIPTION not correct');
     }
+    
+    /**
+     * test ical cli export with a empty Calendar
+     * 
+     */
+    public function testCliExportEmptyCalendar()
+    {
+        $cli = new Calendar_Frontend_Cli();
+        try {
+            $cli->exportICS(new Zend_Console_Getopt('abp:', array($this->_testCalendar->getId())));
+            $this->fail('Expected tinbase exception.');
+        } catch (Tinebase_Exception $e){
+            $this->assertTrue(true);
+        }
+    }
 }
index ff7dd0c..f1b03cd 100644 (file)
@@ -72,6 +72,9 @@ class Calendar_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
 
         ));
         $result = Calendar_Controller_MSEventFacade::getInstance()->search($filter, null, false, false, 'get');
+        if ($result->count() == 0) {
+            throw new Tinebase_Exception('this calendar does not contain any records.');
+        }
         $converter = Calendar_Convert_Event_VCalendar_Factory::factory("generic");
         $result = $converter->fromTine20RecordSet($result);
         print $result->serialize();