Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.

Implementation of EXACT dummy function #563

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Classes/PHPExcel/Calculation/TextData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions unitTests/Classes/PHPExcel/Calculation/TextDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 4 additions & 4 deletions unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions unitTests/rawTestData/Calculation/TextData/EXACT.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"Hello World", "Hello World", "TRUE"
"Hello World", "hello world", "FALSE"