diff --git a/unitTests/PHPExcel/Calculation/DateTimeTest.php b/unitTests/PHPExcel/Calculation/DateTimeTest.php index 3315c07..31676d1 100644 --- a/unitTests/PHPExcel/Calculation/DateTimeTest.php +++ b/unitTests/PHPExcel/Calculation/DateTimeTest.php @@ -52,6 +52,22 @@ class DateTimeTest extends PHPUnit_Framework_TestCase $this->assertEquals($result->format('d-M-Y'),'31-Jan-2012'); } + public function testDATEwith1904Calendar() + { + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); + $result = PHPExcel_Calculation_DateTime::DATE(1918,11,11); + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); + $this->assertEquals($result,5428); + } + + public function testDATEwith1904CalendarError() + { + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904); + $result = PHPExcel_Calculation_DateTime::DATE(1901,1,31); + PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900); + $this->assertEquals($result,'#NUM!'); + } + /** * @dataProvider providerDATEVALUE */ @@ -307,6 +323,22 @@ class DateTimeTest extends PHPUnit_Framework_TestCase return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); } + /** + * @dataProvider providerWORKDAY + */ + public function testWORKDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WORKDAY'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerWORKDAY() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data'); + } + /** * @dataProvider providerEDATE */ @@ -381,4 +413,52 @@ class DateTimeTest extends PHPUnit_Framework_TestCase $this->assertEquals($result->format('d-M-Y'),'31-Dec-2011'); } + /** + * @dataProvider providerDATEDIF + */ + public function testDATEDIF() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEDIF'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerDATEDIF() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data'); + } + + /** + * @dataProvider providerDAYS360 + */ + public function testDAYS360() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYS360'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerDAYS360() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data'); + } + + /** + * @dataProvider providerYEARFRAC + */ + public function testYEARFRAC() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEARFRAC'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerYEARFRAC() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data'); + } + } diff --git a/unitTests/PHPExcel/Calculation/MathTrigTest.php b/unitTests/PHPExcel/Calculation/MathTrigTest.php index db1b67d..ee8b1f4 100644 --- a/unitTests/PHPExcel/Calculation/MathTrigTest.php +++ b/unitTests/PHPExcel/Calculation/MathTrigTest.php @@ -239,6 +239,120 @@ class MathTrigTest extends PHPUnit_Framework_TestCase return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data'); } + /** + * @dataProvider providerMOD + */ + public function testMOD() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerMOD() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data'); + } + + /** + * @dataProvider providerMDETERM + */ + public function testMDETERM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerMDETERM() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data'); + } + + /** + * @dataProvider providerMINVERSE + */ + public function testMINVERSE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerMINVERSE() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data'); + } + + /** + * @dataProvider providerMROUND + */ + public function testMROUND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'),$args); + PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerMROUND() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data'); + } + + /** + * @dataProvider providerROUNDUP + */ + public function testROUNDUP() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerROUNDUP() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data'); + } + + /** + * @dataProvider providerROUNDDOWN + */ + public function testROUNDDOWN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerROUNDDOWN() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data'); + } + + /** + * @dataProvider providerROMAN + */ + public function testROMAN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerROMAN() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data'); + } + /** * @dataProvider providerSQRTPI */ diff --git a/unitTests/PHPExcel/Calculation/TextDataTest.php b/unitTests/PHPExcel/Calculation/TextDataTest.php new file mode 100644 index 0000000..f78f58d --- /dev/null +++ b/unitTests/PHPExcel/Calculation/TextDataTest.php @@ -0,0 +1,338 @@ +assertEquals($expectedResult, $result); + } + + public function providerCHAR() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/CHAR.data'); + } + + /** + * @dataProvider providerCODE + */ + public function testCODE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','ASCIICODE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerCODE() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/CODE.data'); + } + + /** + * @dataProvider providerCONCATENATE + */ + public function testCONCATENATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','CONCATENATE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerCONCATENATE() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/CONCATENATE.data'); + } + + /** + * @dataProvider providerLEFT + */ + public function testLEFT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LEFT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerLEFT() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/LEFT.data'); + } + + /** + * @dataProvider providerMID + */ + public function testMID() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','MID'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerMID() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/MID.data'); + } + + /** + * @dataProvider providerRIGHT + */ + public function testRIGHT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RIGHT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerRIGHT() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/RIGHT.data'); + } + + /** + * @dataProvider providerLOWER + */ + public function testLOWER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','LOWERCASE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerLOWER() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/LOWER.data'); + } + + /** + * @dataProvider providerUPPER + */ + public function testUPPER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','UPPERCASE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerUPPER() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/UPPER.data'); + } + + /** + * @dataProvider providerPROPER + */ + public function testPROPER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','PROPERCASE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerPROPER() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/PROPER.data'); + } + + /** + * @dataProvider providerLEN + */ + public function testLEN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','STRINGLENGTH'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerLEN() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/LEN.data'); + } + + /** + * @dataProvider providerSEARCH + */ + public function testSEARCH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHINSENSITIVE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerSEARCH() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/SEARCH.data'); + } + + /** + * @dataProvider providerFIND + */ + public function testFIND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHSENSITIVE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerFIND() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/FIND.data'); + } + + /** + * @dataProvider providerREPLACE + */ + public function testREPLACE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','REPLACE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerREPLACE() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/REPLACE.data'); + } + + /** + * @dataProvider providerSUBSTITUTE + */ + public function testSUBSTITUTE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','SUBSTITUTE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerSUBSTITUTE() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/SUBSTITUTE.data'); + } + + /** + * @dataProvider providerTRIM + */ + public function testTRIM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMSPACES'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerTRIM() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/TRIM.data'); + } + + /** + * @dataProvider providerCLEAN + */ + public function testCLEAN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMNONPRINTABLE'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerCLEAN() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/CLEAN.data'); + } + + /** + * @dataProvider providerDOLLAR + */ + public function testDOLLAR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','DOLLAR'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerDOLLAR() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data'); + } + + /** + * @dataProvider providerFIXED + */ + public function testFIXED() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','FIXEDFORMAT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerFIXED() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/FIXED.data'); + } + + /** + * @dataProvider providerT + */ + public function testT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','RETURNSTRING'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerT() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/T.data'); + } + + /** + * @dataProvider providerTEXT + */ + public function testTEXT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TEXTFORMAT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerTEXT() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data'); + } + +}