Allow array definitions in test data files

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85784 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-01-26 20:07:17 +00:00
parent f0959c9ef3
commit 97ea12ef6d
1 changed files with 44 additions and 24 deletions

View File

@ -59,6 +59,14 @@ class testDataFileIterator implements Iterator
// Split data into an array of individual values and a result
$dataSet = explode(',',$testData);
foreach($dataSet as &$dataValue) {
$dataValue = $this->_parseDataValue($dataValue);
}
unset($dataValue);
return $dataSet;
}
private function _parseDataValue($dataValue) {
// discard any white space
$dataValue = trim($dataValue);
// test for the required datatype and convert accordingly
@ -69,6 +77,20 @@ class testDataFileIterator implements Iterator
$dataValue = '';
} elseif(($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) {
$dataValue = substr($dataValue,1,-1);
} elseif(($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) {
$dataValue = explode(';',substr($dataValue,1,-1));
foreach($dataValue as &$dataRow) {
if (strpos($dataRow,'|') !== FALSE) {
$dataRow = explode('|',$dataRow);
foreach($dataRow as &$dataCell) {
$dataCell = $this->_parseDataValue($dataCell);
}
unset($dataCell);
} else {
$dataRow = $this->_parseDataValue($dataRow);
}
}
unset($dataRow);
} else {
switch (strtoupper($dataValue)) {
case 'NULL' : $dataValue = NULL; break;
@ -83,10 +105,8 @@ class testDataFileIterator implements Iterator
$dataValue = (int) $dataValue;
}
}
}
unset($dataValue);
return $dataSet;
return $dataValue;
}
}