Merge pull request #90 from Slamdunk/hotfix/ci-5.2

Make tests compatible with PHP 5.2
This commit is contained in:
Mark Baker 2012-11-24 14:17:06 -08:00
commit 818fba7a16
7 changed files with 26 additions and 7 deletions

View File

@ -36,7 +36,7 @@ if (ini_get('phar.readonly')) {
$pharName = 'PHPExcel.phar';
// target folder
$sourceDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Classes' . DIRECTORY_SEPARATOR;
$sourceDir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Classes' . DIRECTORY_SEPARATOR;
// default meta information
$metaData = array(

View File

@ -48,7 +48,7 @@ $inputFileNames = 'templates/32readwrite*[0-9].xlsx';
if ((isset($argc)) && ($argc > 1)) {
$inputFileNames = array();
for($i = 1; $i < $argc; ++$i) {
$inputFileNames[] = __DIR__ . '/templates/' . $argv[$i];
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
}
} else {
$inputFileNames = glob($inputFileNames);

View File

@ -68,7 +68,7 @@ $inputFileNames = 'templates/32readwrite*[0-9].xlsx';
if ((isset($argc)) && ($argc > 1)) {
$inputFileNames = array();
for($i = 1; $i < $argc; ++$i) {
$inputFileNames[] = __DIR__ . '/templates/' . $argv[$i];
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
}
} else {
$inputFileNames = glob($inputFileNames);

View File

@ -68,7 +68,7 @@ $inputFileNames = 'templates/36write*.xlsx';
if ((isset($argc)) && ($argc > 1)) {
$inputFileNames = array();
for($i = 1; $i < $argc; ++$i) {
$inputFileNames[] = __DIR__ . '/templates/' . $argv[$i];
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
}
} else {
$inputFileNames = glob($inputFileNames);

View File

@ -91,7 +91,7 @@ $inputFileNames = 'templates/36write*.xlsx';
if ((isset($argc)) && ($argc > 1)) {
$inputFileNames = array();
for($i = 1; $i < $argc; ++$i) {
$inputFileNames[] = __DIR__ . '/templates/' . $argv[$i];
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
}
} else {
$inputFileNames = glob($inputFileNames);

View File

@ -1,6 +1,6 @@
<?php
include_once __DIR__.'/Complex.php';
include_once dirname(__FILE__).'/Complex.php';
class complexAssert {

View File

@ -57,7 +57,7 @@ class testDataFileIterator implements Iterator
list($testData) = explode('//',$testDataRow);
// Split data into an array of individual values and a result
$dataSet = str_getcsv($testData,',',"'");
$dataSet = $this->_getcsv($testData, ',', "'");
foreach($dataSet as &$dataValue) {
$dataValue = $this->_parseDataValue($dataValue);
}
@ -66,6 +66,25 @@ class testDataFileIterator implements Iterator
return $dataSet;
}
private function _getcsv($input, $delimiter, $enclosure)
{
if (function_exists('str_getcsv')) {
return str_getcsv($input, $delimiter, $enclosure);
}
$temp = fopen('php://memory', 'rw');
fwrite($temp, $input);
rewind($temp);
$data = fgetcsv($temp, strlen($input), $delimiter, $enclosure);
fclose($temp);
if ($data === false) {
$data = array(null);
}
return $data;
}
private function _parseDataValue($dataValue) {
// discard any white space
$dataValue = trim($dataValue);