PhpSpreadsheet/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php

559 lines
16 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
require_once 'testDataFileIterator.php';
class MathTrigTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
2015-05-17 16:34:30 +00:00
if (!defined('PHPEXCEL_ROOT')) {
2012-07-31 20:56:11 +00:00
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerATAN2
*/
2015-05-17 13:00:02 +00:00
public function testATAN2()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerATAN2()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCEILING
*/
2015-05-17 13:00:02 +00:00
public function testCEILING()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerCEILING()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOMBIN
*/
2015-05-17 13:00:02 +00:00
public function testCOMBIN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerCOMBIN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerEVEN
*/
2015-05-17 13:00:02 +00:00
public function testEVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerEVEN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerODD
*/
2015-05-17 13:00:02 +00:00
public function testODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerODD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACT
*/
2015-05-17 13:00:02 +00:00
public function testFACT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFACT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACTDOUBLE
*/
2015-05-17 13:00:02 +00:00
public function testFACTDOUBLE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFACTDOUBLE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFLOOR
*/
2015-05-17 13:00:02 +00:00
public function testFLOOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFLOOR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerGCD
*/
2015-05-17 13:00:02 +00:00
public function testGCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerGCD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLCM
*/
2015-05-17 13:00:02 +00:00
public function testLCM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerLCM()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerINT
*/
2015-05-17 13:00:02 +00:00
public function testINT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
2012-07-31 20:56:11 +00:00
public function providerINT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSIGN
*/
2015-05-17 13:00:02 +00:00
public function testSIGN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSIGN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPOWER
*/
2015-05-17 13:00:02 +00:00
public function testPOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerPOWER()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLOG
*/
2015-05-17 13:00:02 +00:00
public function testLOG()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerLOG()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMOD
*/
2015-05-17 13:00:02 +00:00
public function testMOD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMOD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMDETERM
*/
2015-05-17 13:00:02 +00:00
public function testMDETERM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMDETERM()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMINVERSE
*/
2015-05-17 13:00:02 +00:00
public function testMINVERSE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMINVERSE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMMULT
*/
2015-05-17 13:00:02 +00:00
public function testMMULT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMMULT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMULTINOMIAL
*/
2015-05-17 13:00:02 +00:00
public function testMULTINOMIAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMULTINOMIAL()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMROUND
*/
2015-05-17 13:00:02 +00:00
public function testMROUND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'), $args);
2015-05-17 13:00:02 +00:00
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY);
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMROUND()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPRODUCT
*/
2015-05-17 13:00:02 +00:00
public function testPRODUCT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerPRODUCT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerQUOTIENT
*/
2015-05-17 13:00:02 +00:00
public function testQUOTIENT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerQUOTIENT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDUP
*/
2015-05-17 13:00:02 +00:00
public function testROUNDUP()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerROUNDUP()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDDOWN
*/
2015-05-17 13:00:02 +00:00
public function testROUNDDOWN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerROUNDDOWN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSERIESSUM
*/
2015-05-17 13:00:02 +00:00
public function testSERIESSUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSERIESSUM()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSUMSQ
*/
2015-05-17 13:00:02 +00:00
public function testSUMSQ()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSUMSQ()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerTRUNC
*/
2015-05-17 13:00:02 +00:00
public function testTRUNC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerTRUNC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROMAN
*/
2015-05-17 13:00:02 +00:00
public function testROMAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
2012-07-31 20:56:11 +00:00
public function providerROMAN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSQRTPI
*/
2015-05-17 13:00:02 +00:00
public function testSQRTPI()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSQRTPI()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
}
/**
* @dataProvider providerSUMIF
*/
public function testSUMIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig', 'SUMIF'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
public function providerSUMIF()
{
return array(
array(
array(
array(1),
array(5),
array(10),
),
'>=5',
15,
),
array(
array(
array('text'),
array(2),
),
'=text',
array(
array(10),
array(100),
),
10,
),
array(
array(
array('"text with quotes"'),
array(2),
),
'="text with quotes"',
array(
array(10),
array(100),
),
10,
),
array(
array(
array('"text with quotes"'),
array(''),
),
'>"', // Compare to the single characater " (double quote)
array(
array(10),
array(100),
),
10
),
array(
array(
array(''),
array('anything'),
),
'>"', // Compare to the single characater " (double quote)
array(
array(10),
array(100),
),
100
),
);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
}