From 47c77da24ae1674e4cdf0ca99bf1b8a250d3b4ed Mon Sep 17 00:00:00 2001 From: ehoppe Date: Mon, 11 May 2015 10:13:36 +0200 Subject: [PATCH 1/3] Fix: PHP 5.3 Support --- unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php b/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php index f635dbb87..4265d27d4 100644 --- a/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php +++ b/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php @@ -26,9 +26,9 @@ public function testInvalidXML($filename) public function providerInvalidXML() { - $tests = []; + $tests = array(); foreach(glob('rawTestData/Reader/XEETestInvalid*.xml') as $file) { - $tests[] = [realpath($file), true]; + $tests[] = array(realpath($file), true); } return $tests; } @@ -45,9 +45,9 @@ public function testValidXML($filename, $expectedResult) public function providerValidXML() { - $tests = []; + $tests = array(); foreach(glob('rawTestData/Reader/XEETestValid*.xml') as $file) { - $tests[] = [realpath($file), file_get_contents($file)]; + $tests[] = array(realpath($file), file_get_contents($file)); } return $tests; } From 4cc8b21aa24fa0312679140c499303f7dee30edb Mon Sep 17 00:00:00 2001 From: ehoppe Date: Mon, 11 May 2015 10:15:16 +0200 Subject: [PATCH 2/3] Feature: Initial implementation of EXACT function --- Classes/PHPExcel/Calculation/TextData.php | 22 +++++++++++++++++++ .../PHPExcel/Calculation/TextDataTest.php | 16 ++++++++++++++ .../Calculation/TextData/EXACT.data | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 unitTests/rawTestData/Calculation/TextData/EXACT.data diff --git a/Classes/PHPExcel/Calculation/TextData.php b/Classes/PHPExcel/Calculation/TextData.php index 6461d0601..c6b462f72 100644 --- a/Classes/PHPExcel/Calculation/TextData.php +++ b/Classes/PHPExcel/Calculation/TextData.php @@ -225,6 +225,28 @@ public static function DOLLAR($value = 0, $decimals = 2) } + /** + * The Microsoft Excel EXACT function compares two strings + * and returns TRUE if both values are the same. Otherwise, it will return FALSE. + * + * Note: The EXACT function is case-sensitive when it compares the two strings. + * + * @param string $text1 + * @param string $text2 + * @return string + */ + public static function EXACT($text1, $text2) { + $text1 = PHPExcel_Calculation_Functions::flattenSingleValue($text1); + $text2 = PHPExcel_Calculation_Functions::flattenSingleValue($text2); + + if(is_string($text1) && is_string($text2)){ + if(0 === strcmp($text1, $text2)){ + return PHPExcel_Calculation::getTRUE(); + } + } + // @TODO Should divergent types be handled by this function (integer ...)? + return PHPExcel_Calculation::getFALSE(); + } // function EXACT() /** * SEARCHSENSITIVE diff --git a/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php b/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php index 4b1caf517..13bf15acc 100644 --- a/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php +++ b/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php @@ -289,6 +289,22 @@ public function providerDOLLAR() return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data'); } + /** + * @dataProvider providerEXACT + */ + public function testEXACT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','EXACT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerEXACT() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/EXACT.data'); + } + /** * @dataProvider providerFIXED */ diff --git a/unitTests/rawTestData/Calculation/TextData/EXACT.data b/unitTests/rawTestData/Calculation/TextData/EXACT.data new file mode 100644 index 000000000..de50e9f68 --- /dev/null +++ b/unitTests/rawTestData/Calculation/TextData/EXACT.data @@ -0,0 +1,2 @@ +"Hello World", "Hello World", "TRUE" +"Hello World", "hello world", "FALSE" \ No newline at end of file From 9b02cd70fd90960f4c3f8ea8553f8252455e396f Mon Sep 17 00:00:00 2001 From: marvinGitHub Date: Mon, 11 May 2015 11:51:47 +0200 Subject: [PATCH 3/3] Update EXACT.data --- unitTests/rawTestData/Calculation/TextData/EXACT.data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitTests/rawTestData/Calculation/TextData/EXACT.data b/unitTests/rawTestData/Calculation/TextData/EXACT.data index de50e9f68..c0bedeff8 100644 --- a/unitTests/rawTestData/Calculation/TextData/EXACT.data +++ b/unitTests/rawTestData/Calculation/TextData/EXACT.data @@ -1,2 +1,2 @@ "Hello World", "Hello World", "TRUE" -"Hello World", "hello world", "FALSE" \ No newline at end of file +"Hello World", "hello world", "FALSE"