From 166311bf69515b5e98f4fa16fe3bcb2a50713d69 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 23 Jan 2012 23:41:37 +0000 Subject: [PATCH] Unit Test scripts git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85690 2327b42d-5241-43d6-9e2a-de5ac946f064 --- unitTests/phpunit.xml | 2 ++ unitTests/testDataFileIterator.php | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/unitTests/phpunit.xml b/unitTests/phpunit.xml index 4186581..a0fbfc1 100644 --- a/unitTests/phpunit.xml +++ b/unitTests/phpunit.xml @@ -34,5 +34,7 @@ yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/> + + diff --git a/unitTests/testDataFileIterator.php b/unitTests/testDataFileIterator.php index f183887..e5bd1ea 100644 --- a/unitTests/testDataFileIterator.php +++ b/unitTests/testDataFileIterator.php @@ -47,8 +47,21 @@ class testDataFileIterator implements Iterator private function _parseNextDataset() { - $dataSet = explode(',',trim(fgets($this->file))); + // Read a line of test data from the file + do { + // Only take lines that contain test data and that aren't commented out + $testDataRow = trim(fgets($this->file)); + } while (($testDataRow > '') && ($testDataRow{0} === '#')); + + // Discard any comments at the end of the line + list($testData) = explode('//',$testDataRow); + + // Split data into an array of individual values and a result + $dataSet = explode(',',$testData); foreach($dataSet as &$dataValue) { + // discard any white space + $dataValue = trim($dataValue); + // test for the required datatype and convert accordingly if (!is_numeric($dataValue)) { if($dataValue == '') { $dataValue = NULL; @@ -64,7 +77,7 @@ class testDataFileIterator implements Iterator } } } else { - if (is_float($dataValue)) { + if (strpos($dataValue,'.') !== FALSE) { $dataValue = (float) $dataValue; } else { $dataValue = (int) $dataValue;