Merge branch '2015.11-sambaad' into 2015.11
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 5 Apr 2016 13:58:08 +0000 (15:58 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 5 Apr 2016 13:58:08 +0000 (15:58 +0200)
13 files changed:
tests/tine20/Addressbook/Export/DocTest.php
tests/tine20/Addressbook/JsonTest.php
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Convert/Event/VCalendar/GenericTest.php
tests/tine20/Crm/Export/XlsTest.php
tests/tine20/Sales/InvoiceExportTests.php
tests/tine20/Zend/Ldap/ConvertTest.php
tine20/Timetracker/Export/Ods/Timesheet.php
tine20/Tinebase/Frontend/Json.php
tine20/Tinebase/Frontend/Json/Abstract.php
tine20/composer.json
tine20/composer.lock
tine20/library/Zend/Locale/Format.php

index 21fdbff..cfca71e 100644 (file)
@@ -24,6 +24,14 @@ class Addressbook_Export_DocTest extends TestCase
 {
     public function testExportLetter()
     {
+        // skip tests for php7
+        // ERROR: PHP Fatal error:  Cannot use PhpOffice\PhpWord\Shared\String as String because 'String' is a special
+        //  class name in /usr/local/share/tine20.git/tine20/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php
+        //  on line 23
+        if (PHP_VERSION_ID >= 70000) {
+            $this->markTestSkipped('FIXME in php7');
+        }
+
         $filter = new Addressbook_Model_ContactFilter(array(
             array('field' => 'n_given', 'operator' => 'equals', 'value' => 'Robert')
         ));
index 6ab5621..2716db2 100644 (file)
@@ -844,14 +844,20 @@ class Addressbook_JsonTest extends TestCase
         $ns = $xml->getNamespaces(true);
         $spreadsheetXml = $xml->children($ns['office'])->{'body'}->{'spreadsheet'};
         
-        $headerRowXml = $spreadsheetXml->children($ns['table'])->{'table'}->{'table-row'}->{1};
+        $headerRowXml = $spreadsheetXml->children($ns['table'])->{'table'}->xpath('table:table-row');
+        $headerRowXml = $headerRowXml[1];
+        $cells = $headerRowXml->xpath('table:table-cell');
+        $tag1 = $cells[1]->xpath('text:p');
+        $tag1 = $tag1[0];
+        $tag2 = $cells[2]->xpath('text:p');
+        $tag2 = $tag2[0];
         
         // the tags should exist in the header row
-        $this->assertEquals('tag1', (string) $headerRowXml->children($ns['table'])->{'table-cell'}->{1}->children($ns['text'])->{0});
-        $this->assertEquals('tag2', (string) $headerRowXml->children($ns['table'])->{'table-cell'}->{2}->children($ns['text'])->{0});
+        $this->assertEquals('tag1', (string) $tag1);
+        $this->assertEquals('tag2', (string) $tag2);
         
         // if there is no more header column, tag3 is not shown
-        $this->assertEquals(3, (string) $headerRowXml->children($ns['table'])->{'table-cell'}->count());
+        $this->assertEquals(3, count($cells));
     }
     
     /**
@@ -1745,4 +1751,18 @@ Steuernummer 33/111/32212";
             $this->assertCount(2, $contactData['tags'], $contactData['n_fn'] . ' tags failed');
         }
     }
+
+    /**
+     * @see 0011704: PHP 7 can't decode empty JSON-strings
+     */
+    public function testEmptyPagingParamJsonDecode()
+    {
+        $filter = array(array(
+            'field'    => 'n_family',
+            'operator' => 'equals',
+            'value'    => 'somename'
+        ));
+        $result = $this->_instance->searchContacts($filter, '');
+        $this->assertEquals(0, $result['totalcount']);
+    }
 }
index 0a7b169..a16c04b 100644 (file)
@@ -1473,12 +1473,12 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
     public function testBrokenTimezoneInEvent()
     {
         $event = $this->_getEvent(true);
-        $event->originator_tz = 'AWST';
+        $event->originator_tz = 'AWSTTTT';
         try {
             $event = $this->_controller->create($event);
             $this->fail('should throw Tinebase_Exception_Record_Validation because of bad TZ: ' . print_r($event->toArray(), true));
         } catch (Tinebase_Exception_Record_Validation $terv) {
-            $this->assertEquals('Bad Timezone: AWST', $terv->getMessage());
+            $this->assertEquals('Bad Timezone: AWSTTTT', $terv->getMessage());
         }
     }
 }
index 489b579..ab328b1 100644 (file)
@@ -768,7 +768,7 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
     public function testBrokenTimezoneInTineEvent()
     {
         $event = $this->testConvertRepeatingAllDayDailyEventToTine20Model();
-        $event->originator_tz = 'AWST'; // Australian Western Standard Time
+        $event->originator_tz = 'AWSTTTT'; // Australian Western Standard Time TTT
 
         $this->_converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_GENERIC);
 
@@ -776,7 +776,7 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
             $vevent = $this->_converter->fromTine20Model($event)->serialize();
             $this->fail('should throw Tinebase_Exception_Record_Validation because of bad TZ');
         } catch (Tinebase_Exception_Record_Validation $terv) {
-            $this->assertEquals('Bad Timezone: AWST', $terv->getMessage());
+            $this->assertEquals('Bad Timezone: AWSTTTT', $terv->getMessage());
         }
     }
 }
index 4ff2244..8976e1a 100644 (file)
@@ -63,6 +63,12 @@ class Crm_Export_XlsTest extends Crm_Export_AbstractTest
      */
     public function testExportXls()
     {
+        // skip tests for php7
+        // PHP Fatal error:  'break' not in the 'loop' or 'switch' context in /usr/local/share/tine20.git/tine20/vendor/codeplex/phpexcel/PHPExcel/Calculation/Functions.php on line 574
+        if (PHP_VERSION_ID >= 70000) {
+            $this->markTestSkipped('FIXME in php7');
+        }
+        
         $translate = Tinebase_Translation::getTranslation('Crm');
         $excelObj = $this->_instance->generate();
         
index 9f3a50f..e53de1a 100644 (file)
@@ -155,15 +155,11 @@ class Sales_InvoiceExportTests extends Sales_InvoiceTestCase
     
         $ns = $xml->getNamespaces(true);
         $spreadsheetXml = $xml->children($ns['office'])->{'body'}->{'spreadsheet'};
+
+        $text = $spreadsheetXml->xpath('((.//table:table/table:table-row)[2]/table:table-cell)[4]/text:p');
+        $text = $text[0];
     
         // the product should be found here
-        $this->assertEquals('Debitor', (string) $spreadsheetXml->children(
-                $ns['table']
-            )->{'table'}->{'table-row'}->{1}->children(
-                $ns['table']
-            )->{'table-cell'}->{3}->children(
-                $ns['text']
-            )->{0}
-        );
+        $this->assertEquals('Debitor', (string)$text);
     }
 }
index 93fce5d..ce7cfe5 100644 (file)
@@ -24,7 +24,7 @@ class Zend_Ldap_ConvertTest extends TestCase
 
     public function testHex32ToAsc()
     {
-        $result = $this->_getUit()->hex32ToAsc('0x0C');
-        $this->assertEquals('12', $result);
+        $result = $this->_getUit()->hex32ToAsc('\\4D');
+        $this->assertTrue('M' === $result, print_r($result, true) . ' is no string value "M"');
     }
 }
index e5a3ebd..b26a995 100644 (file)
@@ -88,7 +88,7 @@ class Timetracker_Export_Ods_Timesheet extends Tinebase_Export_Spreadsheet_Ods
         
         switch($_param['type']) {
             case 'timeaccount':
-                $value = $this->_resolvedRecords['timeaccounts'][$this->_resolvedRecords['timeaccounts']->getIndexById($_record->timeaccount_id)]->$_param['field'];
+                $value = $this->_resolvedRecords['timeaccounts'][$this->_resolvedRecords['timeaccounts']->getIndexById($_record->timeaccount_id)]->{$_param['field']};
                 break;
         }
         return $value;
index 3a9c415..82c561e 100644 (file)
@@ -929,7 +929,7 @@ class Tinebase_Frontend_Json extends Tinebase_Frontend_Json_Abstract
      */
     public function searchPreferencesForApplication($applicationName, $filter)
     {
-        $decodedFilter = is_array($filter) ? $filter : Zend_Json::decode($filter);
+        $decodedFilter = $this->_prepareParameter($filter);
         
         $filter = new Tinebase_Model_PreferenceFilter();
         if (! empty($decodedFilter)) {
@@ -992,7 +992,7 @@ class Tinebase_Frontend_Json extends Tinebase_Frontend_Json_Abstract
      */
     public function savePreferences($data, $adminMode)
     {
-        $decodedData = is_array($data) ? $data : Zend_Json::decode($data);
+        $decodedData = $this->_prepareParameter($data);
         
         $result = array();
         foreach ($decodedData as $applicationName => $data) {
index 1cd6116..82c5b8a 100644 (file)
@@ -189,7 +189,7 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
      */
     protected function _search($_filter, $_paging, Tinebase_Controller_SearchInterface $_controller, $_filterModel, $_getRelations = FALSE, $_totalCountMethod = self::TOTALCOUNT_CONTROLLER)
     {
-        $decodedPagination = is_array($_paging) ? $_paging : Zend_Json::decode($_paging);
+        $decodedPagination = $this->_prepareParameter($_paging);
         $pagination = new Tinebase_Model_Pagination($decodedPagination);
         $filter = $this->_decodeFilter($_filter, $_filterModel);
         
@@ -217,7 +217,7 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
     protected function _decodeFilter($_filter, $_filterModel, $_throwExceptionIfEmpty = FALSE)
     {
         $filterModel = $this->_getPluginForFilterModel($_filterModel);
-        $decodedFilter = is_array($_filter) || strlen($_filter) == 40 ? $_filter : Zend_Json::decode($_filter);
+        $decodedFilter = is_array($_filter) || strlen($_filter) == 40 ? $_filter : $this->_prepareParameter($_filter);
 
         if (is_array($decodedFilter)) {
             $filter = new $filterModel(array());
@@ -308,7 +308,7 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
     protected function _updateMultiple($_filter, $_data, Tinebase_Controller_Record_Interface $_controller, $_filterModel)
     {
         $this->_longRunningRequest();
-        $decodedData   = is_array($_data) ? $_data : Zend_Json::decode($_data);
+        $decodedData   = $this->_prepareParameter($_data);
         $filter = $this->_decodeFilter($_filter, $_filterModel, TRUE);
         
         $result = $_controller->updateMultiple($filter, $decodedData);
@@ -371,7 +371,7 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
     protected function _delete($_ids, Tinebase_Controller_Record_Interface $_controller, $additionalArguments = array())
     {
         if (! is_array($_ids) && strpos($_ids, '[') !== false) {
-            $_ids = Zend_Json::decode($_ids);
+            $_ids = $this->_prepareParameter($_ids);
         }
         $args = array_merge(array($_ids), $additionalArguments);
         call_user_func_array(array($_controller, 'delete'), $args);
@@ -435,6 +435,28 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
     }
 
     /**
+     * returns function parameter as object, decode Json if needed
+     *
+     * Prepare function input to be an object. Input maybe already an array or (empty) text.
+     * Starting PHP 7 Zend_Json::decode can't handle empty strings.
+     *
+     * @param  mixed $_dataAsArrayOrJson
+     * @return array
+     */
+    protected function _prepareParameter($_dataAsArrayOrJson)
+    {
+        if (is_array($_dataAsArrayOrJson)) {
+            return $_dataAsArrayOrJson;
+        }
+        else if (trim($_dataAsArrayOrJson) == '') {
+            return Zend_Json::decode("{}");
+        }
+        else {
+            return Zend_Json::decode($_dataAsArrayOrJson);
+        }
+    }
+
+    /**
      * returns record prepared for json transport
      *
      * @param Tinebase_Record_Interface $_record
index e8d91cd..c805cf8 100644 (file)
@@ -28,7 +28,7 @@
         "phpoffice/phpword": "0.12.*",
         "sabre/dav": "1.8.*",
         "sabre/vobject": "3.1.3 as 2.1.313",
-        "metaways/opendocument": "1.0",
+        "metaways/opendocument": "1.1",
         "metaways/timezoneconvert": "0.2",
         "zendframework/zend-http": "2.2.8-p3 as 2.2.8"
     },
index a17b82d..56a8ad7 100644 (file)
         },
         {
             "name": "metaways/opendocument",
-            "version": "1.0",
+            "version": "1.1",
             "source": {
                 "type": "git",
                 "url": "http://git.tine20.org/git/opendocument",
-                "reference": "65e8d1907f32b18b301711dc46049928d9f14bb0"
+                "reference": "ccabf8e726792e0f034d097581084c459af2011e"
             },
             "require": {
                 "php": ">=5.3.0"
                 "OpenDocument",
                 "Template"
             ],
-            "time": "2015-01-29 12:15:38"
+            "time": "2016-04-01 11:09:24"
         },
         {
             "name": "metaways/timezoneconvert",
index f889ce5..c57ceab 100644 (file)
@@ -299,7 +299,7 @@ class Zend_Locale_Format
 
         // Get correct signs for this locale
         $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols');
-        iconv_set_encoding('internal_encoding', 'UTF-8');
+        @iconv_set_encoding('internal_encoding', 'UTF-8');
 
         // Get format
         $format = $options['number_format'];