From 2fc22c490b13a91082f82f69c0b23fc3508cafae Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Tue, 23 Oct 2018 10:53:35 +0900 Subject: [PATCH] Updated CI config for Travis, preload OLE (#16) * Test only on supported PHP versions on Travis CI. * Preload OLE.php as contains important constants. Were getting: Use of undefined constant OLE_PPS_TYPE_FILE - assumed 'OLE_PPS_TYPE_FILE' (this will throw an Error in a future version of PHP) in OLE/PPS/File.php:60 * Forbid installing on PHP 7.3 for time being. pear/OLE does not really work on PHP 7.3, so this package is also unusable there. --- .travis.yml | 6 ++++-- Spreadsheet/Excel/Writer/Workbook.php | 4 ++++ composer.json | 4 ++-- test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e51088..ecdc289 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,11 @@ sudo: false language: php php: - - 5.3 - - 5.4 - 5.5 - 5.6 + - 7.0 - 7.1 + - 7.2 cache: directories: @@ -15,3 +15,5 @@ cache: install: - composer install --prefer-dist +script: + - php vendor/bin/phpunit diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 4c9e525..3c779ec 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -39,6 +39,10 @@ if (!class_exists('Spreadsheet_Excel_Writer_BIFFwriter')) { require_once 'Spreadsheet/Excel/Writer/Parser.php'; } +if (!class_exists('OLE')) { + require_once 'OLE.php'; +} + if (!class_exists('OLE_PPS_Root')) { require_once 'OLE/PPS/Root.php'; } diff --git a/composer.json b/composer.json index df6faed..98fc7ce 100644 --- a/composer.json +++ b/composer.json @@ -51,8 +51,8 @@ "type": "library", "require": { "pear/pear-core-minimal": "^1.10", - "pear/ole": "*", - "php": ">=5.3.3" + "pear/ole": ">=1.0.0RC3", + "php": ">=5.3.3 <7.3" }, "require-dev": { "phpunit/phpunit": "<6.0" diff --git a/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php b/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php index a7416ef..301c4c9 100644 --- a/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php +++ b/test/Test/Spreadsheet/Excel/Writer/WorkbookTest.php @@ -6,6 +6,12 @@ */ class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_WriterTestCase { + public static function setUpBeforeClass() + { + // Preload constants from OLE + @class_exists(OLE::class); + } + public function testSetVersion() { $workbook = $this->getNewWorkbook();