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/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; } diff --git a/unitTests/rawTestData/Calculation/TextData/EXACT.data b/unitTests/rawTestData/Calculation/TextData/EXACT.data new file mode 100644 index 000000000..c0bedeff8 --- /dev/null +++ b/unitTests/rawTestData/Calculation/TextData/EXACT.data @@ -0,0 +1,2 @@ +"Hello World", "Hello World", "TRUE" +"Hello World", "hello world", "FALSE"