Skip to content

Commit

Permalink
Merge pull request PHPOffice#90 from Slamdunk/hotfix/ci-5.2
Browse files Browse the repository at this point in the history
Make tests compatible with PHP 5.2
  • Loading branch information
Mark Baker committed Nov 24, 2012
2 parents ddbce8e + 06293c7 commit 818fba7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Build/build-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$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(
Expand Down
2 changes: 1 addition & 1 deletion Examples/32chartreadwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion Examples/35chartrender.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion Examples/36chartreadwriteHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion Examples/36chartreadwritePDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion unitTests/custom/complexAssert.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include_once __DIR__.'/Complex.php';
include_once dirname(__FILE__).'/Complex.php';


class complexAssert {
Expand Down
21 changes: 20 additions & 1 deletion unitTests/testDataFileIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function _parseNextDataset()
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);
}
Expand All @@ -66,6 +66,25 @@ private function _parseNextDataset()
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);
Expand Down

0 comments on commit 818fba7

Please sign in to comment.