From a77c44d4e66cce9ef526d18d607a9199f12fafae Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Wed, 25 Jan 2012 22:05:38 +0000 Subject: [PATCH] Unit Test scripts git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85741 2327b42d-5241-43d6-9e2a-de5ac946f064 --- .../PHPExcel/Calculation/DateTimeTest.php | 258 ++++++++++++++++++ .../PHPExcel/Calculation/MathTrigTest.php | 54 +++- 2 files changed, 306 insertions(+), 6 deletions(-) create mode 100644 unitTests/PHPExcel/Calculation/DateTimeTest.php diff --git a/unitTests/PHPExcel/Calculation/DateTimeTest.php b/unitTests/PHPExcel/Calculation/DateTimeTest.php new file mode 100644 index 00000000..2ed842a5 --- /dev/null +++ b/unitTests/PHPExcel/Calculation/DateTimeTest.php @@ -0,0 +1,258 @@ +assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerDATE() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data'); + } + + /** + * @dataProvider providerDATEVALUE + */ + public function testDATEVALUE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEVALUE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerDATEVALUE() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data'); + } + + /** + * @dataProvider providerYEAR + */ + public function testYEAR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEAR'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerYEAR() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data'); + } + + /** + * @dataProvider providerMONTH + */ + public function testMONTH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MONTHOFYEAR'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerMONTH() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data'); + } + + /** + * @dataProvider providerWEEKNUM + */ + public function testWEEKNUM() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WEEKOFYEAR'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerWEEKNUM() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data'); + } + + /** + * @dataProvider providerWEEKDAY + */ + public function testWEEKDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFWEEK'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerWEEKDAY() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data'); + } + + /** + * @dataProvider providerDAY + */ + public function testDAY() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFMONTH'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerDAY() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data'); + } + + /** + * @dataProvider providerTIME + */ + public function testTIME() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIME'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerTIME() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data'); + } + + /** + * @dataProvider providerTIMEVALUE + */ + public function testTIMEVALUE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIMEVALUE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerTIMEVALUE() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data'); + } + + /** + * @dataProvider providerHOUR + */ + public function testHOUR() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','HOUROFDAY'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerHOUR() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data'); + } + + /** + * @dataProvider providerMINUTE + */ + public function testMINUTE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MINUTEOFHOUR'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerMINUTE() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data'); + } + + /** + * @dataProvider providerSECOND + */ + public function testSECOND() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','SECONDOFMINUTE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerSECOND() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data'); + } + + /** + * @dataProvider providerNETWORKDAYS + */ + public function testNETWORKDAYS() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','NETWORKDAYS'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerNETWORKDAYS() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); + } + + /** + * @dataProvider providerEDATE + */ + public function testEDATE() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EDATE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerEDATE() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data'); + } + + /** + * @dataProvider providerEOMONTH + */ + public function testEOMONTH() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EOMONTH'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerEOMONTH() + { + return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data'); + } + +} diff --git a/unitTests/PHPExcel/Calculation/MathTrigTest.php b/unitTests/PHPExcel/Calculation/MathTrigTest.php index 09eb01e3..aea67a56 100644 --- a/unitTests/PHPExcel/Calculation/MathTrigTest.php +++ b/unitTests/PHPExcel/Calculation/MathTrigTest.php @@ -15,12 +15,6 @@ class MathTrigTest extends PHPUnit_Framework_TestCase require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } -// public function testDUMMY() -// { -// $result = PHPExcel_Calculation_Functions::DUMMY(); -// $this->assertEquals('#Not Yet Implemented', $result); -// } -// /** * @dataProvider providerATAN2 */ @@ -181,4 +175,52 @@ class MathTrigTest extends PHPUnit_Framework_TestCase return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data'); } + /** + * @dataProvider providerINT + */ + public function testINT() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'),$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerINT() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data'); + } + + /** + * @dataProvider providerSIGN + */ + public function testSIGN() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerSIGN() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data'); + } + + /** + * @dataProvider providerPOWER + */ + public function testPOWER() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-12); + } + + public function providerPOWER() + { + return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data'); + } + }