0011730: fix doc export for php7
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 16 Aug 2016 12:26:41 +0000 (14:26 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 17 Aug 2016 13:34:20 +0000 (15:34 +0200)
* adds xls export test
* updates phpexcel and phpword

https://forge.tine20.org/view.php?id=11730

Change-Id: I036d06e16e222f076519aeb527514d7434775e87
Reviewed-on: http://gerrit.tine20.com/customers/3440
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Addressbook/AllTests.php
tests/tine20/Addressbook/Export/DocTest.php
tests/tine20/Addressbook/Export/XlsTest.php [new file with mode: 0644]
tine20/Tinebase/Export/Spreadsheet/Xls.php
tine20/composer.json
tine20/composer.lock

index 235eceb..e8e66d3 100644 (file)
@@ -36,6 +36,7 @@ class Addressbook_AllTests
         $suite->addTestSuite('Addressbook_CliTest');
         $suite->addTestSuite('Addressbook_Model_ContactIdFilterTest');
         $suite->addTestSuite('Addressbook_Export_DocTest');
+        $suite->addTestSuite('Addressbook_Export_XlsTest');
         // TODO: enable this again, when its fast
 //         $suite->addTestSuite('Addressbook_Setup_DemoDataTests');
         return $suite;
index fca918c..4092dc4 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @package     Addressbook
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2008-2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiß <c.weiss@metaways.de>
  */
 
@@ -15,23 +15,11 @@ use \PhpOffice\PhpWord;
  *
  * @package     Addressbook
  * @subpackage  Export
- * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @author      Cornelius Weiß <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2016 Metaways Infosystems GmbH (http://www.metaways.de)
- *
  */
 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 0011730: fix doc export for php7');
-        }
-
         // make sure definition is imported
         $definitionFile = __DIR__ . '/../../../../tine20/Addressbook/Export/definitions/adb_default_doc.xml';
         $app = Tinebase_Application::getInstance()->getApplicationByName('Addressbook');
@@ -50,6 +38,7 @@ class Addressbook_Export_DocTest extends TestCase
     }
 
     // read and write sucks
+    // TODO make this work or remove it
     public function _testReadWriteCycleSucks()
     {
         PhpWord\Settings::setTempDir(Tinebase_Core::getTempDir());
diff --git a/tests/tine20/Addressbook/Export/XlsTest.php b/tests/tine20/Addressbook/Export/XlsTest.php
new file mode 100644 (file)
index 0000000..e5077ad
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Tine 2.0 - http://www.tine20.org
+ *
+ * @package     Addressbook
+ * @license     http://www.gnu.org/licenses/agpl.html
+ * @copyright   Copyright (c) 2008-2016 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Philipp Schüle <p.schuele@metaways.de>
+ */
+
+/**
+ * Addressbook Xls generation class tests
+ *
+ * @package     Addressbook
+ * @subpackage  Export
+ */
+class Addressbook_Export_XlsTest extends TestCase
+{
+    public function testExportXls()
+    {
+        $filter = new Addressbook_Model_ContactFilter(array(
+            array('field' => 'n_given', 'operator' => 'equals', 'value' => 'Robert')
+        ));
+        $export = new Addressbook_Export_Xls($filter);
+        $xls = $export->generate();
+
+        $tempfile = tempnam(Tinebase_Core::getTempDir(), __METHOD__ . '_') . '.xlsx';
+
+        // TODO add a save() fn to Tinebase_Export_Spreadsheet_Xls
+        $xlswriter = PHPExcel_IOFactory::createWriter($xls, 'Excel5');
+        $xlswriter->setPreCalculateFormulas(FALSE);
+        $xlswriter->save($tempfile);
+
+        $this->assertGreaterThan(0, filesize($tempfile));
+    }
+}
index 0874dc7..257334e 100644 (file)
@@ -169,7 +169,7 @@ class Tinebase_Export_Spreadsheet_Xls extends Tinebase_Export_Spreadsheet_Abstra
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Creating and sending xls to client (Format: ' . $xlsFormat . ').');
         $xlswriter = PHPExcel_IOFactory::createWriter($this->_excelObject, $xlsFormat);
         
-        // precalcualting formula values costs tons of time, because sum formulas are like SUM C1:C65000
+        // precalculating formula values costs tons of time, because sum formulas are like SUM C1:C65000
         $xlswriter->setPreCalculateFormulas(FALSE);
         
         $xlswriter->save('php://output');
index ef616c4..4fa956f 100644 (file)
@@ -26,8 +26,8 @@
         "tine20/composerapploader": "dev-master",
         "syncroton/syncroton": "1.1.*",
         "ezyang/htmlpurifier": "v4.6.0",
-        "codeplex/phpexcel": "1.7.8",
-        "phpoffice/phpword": "0.12.*",
+        "phpoffice/phpexcel": "1.8.*",
+        "phpoffice/phpword": "v0.13.*",
         "sabre/dav": "1.8.*",
         "sabre/vobject": "3.1.3 as 2.1.313",
         "metaways/opendocument": "1.1",
index 007a2e7..d92db27 100644 (file)
@@ -4,61 +4,10 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "a572b5d66862ea9828caace85f28af6a",
-    "content-hash": "c6972ff452252a45e53f83b1e7a19c9b",
+    "hash": "7eda7cd093eab9cd041a6b175c4f8879",
+    "content-hash": "db3c77741bea7113ffe6fbf1e770d000",
     "packages": [
         {
-            "name": "codeplex/phpexcel",
-            "version": "1.7.8",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/markushausammann/PHPExcel.git",
-                "reference": "6236b1e1513dda38a68a5ac22bbab5fc2b7942fd"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/markushausammann/PHPExcel/zipball/6236b1e1513dda38a68a5ac22bbab5fc2b7942fd",
-                "reference": "6236b1e1513dda38a68a5ac22bbab5fc2b7942fd",
-                "shasum": ""
-            },
-            "require": {
-                "ext-xml": "*",
-                "php": ">=5.2.0"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "PHPExcel": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "LGPL"
-            ],
-            "authors": [
-                {
-                    "name": "Maarten Balliauw",
-                    "homepage": "http://blog.maartenballiauw.be"
-                },
-                {
-                    "name": "Mark Baker"
-                },
-                {
-                    "name": "Erit Tilt"
-                }
-            ],
-            "description": "PHPExcel - OpenXML - Create Excel2007 documents in PHP - Spreadsheet engine",
-            "homepage": "http://phpexcel.codeplex.com",
-            "keywords": [
-                "OpenXML",
-                "excel",
-                "php",
-                "spreadsheet"
-            ],
-            "abandoned": "phpoffice/phpexcel",
-            "time": "2012-11-21 10:55:52"
-        },
-        {
             "name": "doctrine/annotations",
             "version": "v1.2.7",
             "source": {
             "time": "2014-06-02 12:00:27"
         },
         {
+            "name": "pclzip/pclzip",
+            "version": "2.8.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/ivanlanin/pclzip.git",
+                "reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/ivanlanin/pclzip/zipball/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd",
+                "reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd",
+                "shasum": ""
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "pclzip.lib.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL-2.1"
+            ],
+            "authors": [
+                {
+                    "name": "Vincent Blavet"
+                }
+            ],
+            "description": "A PHP library that offers compression and extraction functions for Zip formatted archives",
+            "homepage": "http://www.phpconcept.net/pclzip",
+            "keywords": [
+                "php",
+                "zip"
+            ],
+            "time": "2014-06-05 11:42:24"
+        },
+        {
+            "name": "phpoffice/common",
+            "version": "v0.2.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/PHPOffice/Common.git",
+                "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/PHPOffice/Common/zipball/c9be70c80637c28c728be78e66aad4878a34f8dd",
+                "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd",
+                "shasum": ""
+            },
+            "require": {
+                "pclzip/pclzip": "^2.8",
+                "php": ">=5.3.0"
+            },
+            "require-dev": {
+                "phpdocumentor/phpdocumentor": "2.*",
+                "phploc/phploc": "2.*",
+                "phpmd/phpmd": "2.*",
+                "phpunit/phpunit": "3.7.*",
+                "sebastian/phpcpd": "2.*",
+                "squizlabs/php_codesniffer": "2.*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "PhpOffice\\Common\\": "src/Common/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL"
+            ],
+            "authors": [
+                {
+                    "name": "Mark Baker"
+                },
+                {
+                    "name": "Franck Lefevre",
+                    "homepage": "http://rootslabs.net"
+                }
+            ],
+            "description": "PHPOffice Common",
+            "homepage": "http://phpoffice.github.io",
+            "keywords": [
+                "common",
+                "component",
+                "office",
+                "php"
+            ],
+            "time": "2016-07-07 17:26:55"
+        },
+        {
+            "name": "phpoffice/phpexcel",
+            "version": "1.8.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/PHPOffice/PHPExcel.git",
+                "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
+                "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
+                "shasum": ""
+            },
+            "require": {
+                "ext-xml": "*",
+                "ext-xmlwriter": "*",
+                "php": ">=5.2.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "PHPExcel": "Classes/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL"
+            ],
+            "authors": [
+                {
+                    "name": "Maarten Balliauw",
+                    "homepage": "http://blog.maartenballiauw.be"
+                },
+                {
+                    "name": "Mark Baker"
+                },
+                {
+                    "name": "Franck Lefevre",
+                    "homepage": "http://blog.rootslabs.net"
+                },
+                {
+                    "name": "Erik Tilt"
+                }
+            ],
+            "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
+            "homepage": "http://phpexcel.codeplex.com",
+            "keywords": [
+                "OpenXML",
+                "excel",
+                "php",
+                "spreadsheet",
+                "xls",
+                "xlsx"
+            ],
+            "time": "2015-05-01 07:00:55"
+        },
+        {
             "name": "phpoffice/phpword",
-            "version": "v0.12.1",
+            "version": "v0.13.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/PHPOffice/PHPWord.git",
-                "reference": "38cb04d322007dd522cbdd8ba3cd50ab67ced0db"
+                "reference": "0a3f873972defb304de4fa2f5f53156558c11a7a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/38cb04d322007dd522cbdd8ba3cd50ab67ced0db",
-                "reference": "38cb04d322007dd522cbdd8ba3cd50ab67ced0db",
+                "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/0a3f873972defb304de4fa2f5f53156558c11a7a",
+                "reference": "0a3f873972defb304de4fa2f5f53156558c11a7a",
                 "shasum": ""
             },
             "require": {
                 "ext-xml": "*",
-                "php": ">=5.3.3"
+                "php": ">=5.3.3",
+                "phpoffice/common": "0.2.*",
+                "zendframework/zend-escaper": "2.4.*",
+                "zendframework/zend-stdlib": "2.4.*",
+                "zendframework/zend-validator": "2.4.*"
             },
             "require-dev": {
                 "dompdf/dompdf": "0.6.*",
                 "phploc/phploc": "2.*",
                 "phpmd/phpmd": "2.*",
                 "phpunit/phpunit": "3.7.*",
-                "sebastian/phpcpd": "2.*",
                 "squizlabs/php_codesniffer": "1.*",
-                "tecnick.com/tcpdf": "6.*"
+                "tecnickcom/tcpdf": "6.*"
             },
             "suggest": {
-                "dompdf/dompdf": "Used to write PDF",
-                "ext-gd2": "Used to add images",
-                "ext-xmlwriter": "Used to write DOCX and ODT",
-                "ext-xsl": "Used to apply XSL style sheet to main document part of OOXML template",
-                "ext-zip": "Used to write DOCX and ODT"
+                "dompdf/dompdf": "Allows writing PDF",
+                "ext-gd2": "Allows adding images",
+                "ext-xmlwriter": "Allows writing OOXML and ODF",
+                "ext-xsl": "Allows applying XSL style sheet to headers, to main document part, and to footers of an OOXML template",
+                "ext-zip": "Allows writing OOXML and ODF"
             },
             "type": "library",
             "autoload": {
                     "homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
                 }
             ],
-            "description": "PHPWord - A pure PHP library for reading and writing word processing documents (DOCX, ODT, RTF, HTML, PDF)",
+            "description": "PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)",
             "homepage": "http://phpoffice.github.io",
             "keywords": [
                 "ISO IEC 29500",
                 "doc",
                 "docx",
                 "html",
+                "odf",
                 "odt",
                 "office",
                 "pdf",
                 "word",
                 "writer"
             ],
-            "time": "2015-08-30 14:30:44"
+            "time": "2016-07-31 08:53:39"
         },
         {
             "name": "sabre/dav",