PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php

562 lines
15 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
2012-07-31 20:56:11 +00:00
use PhpOffice\PhpSpreadsheet\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
2016-03-22 14:35:50 +00:00
class MathTrigTest extends \PHPUnit_Framework_TestCase
2012-07-31 20:56:11 +00:00
{
public function setUp()
{
Functions::setCompatibilityMode(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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/ATAN2.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/CEILING.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/COMBIN.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/EVEN.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/ODD.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/FACT.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/FLOOR.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/GCD.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/LCM.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/INT.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/SIGN.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/POWER.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, 'logBase'], $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()
{
return require 'data/Calculation/MathTrig/LOG.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/MOD.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/MDETERM.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMINVERSE
* @group fail19
2012-07-31 20:56:11 +00:00
*/
2015-05-17 13:00:02 +00:00
public function testMINVERSE()
{
$this->markTestIncomplete('TODO: This test should be fixed');
2015-05-17 13:00:02 +00:00
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/MINVERSE.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMMULT
* @group fail19
2012-07-31 20:56:11 +00:00
*/
2015-05-17 13:00:02 +00:00
public function testMMULT()
{
$this->markTestIncomplete('TODO: This test should be fixed');
2015-05-17 13:00:02 +00:00
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/MMULT.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
2015-05-17 13:00:02 +00:00
}
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);
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
$result = call_user_func_array([MathTrig::class, 'MROUND'], $args);
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
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 providerMROUND()
{
return require 'data/Calculation/MathTrig/MROUND.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/PRODUCT.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/QUOTIENT.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/ROUNDUP.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/SERIESSUM.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/SUMSQ.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/TRUNC.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/ROMAN.php';
2015-05-17 13:00:02 +00:00
}
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);
$result = call_user_func_array([MathTrig::class, '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()
{
return require 'data/Calculation/MathTrig/SQRTPI.php';
}
/**
* @dataProvider providerSUMIF
*/
public function testSUMIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([MathTrig::class, 'SUMIF'], $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
public function providerSUMIF()
{
return [
[
[
[1],
[5],
[10],
],
'>=5',
15,
],
[
[
['text'],
[2],
],
'=text',
[
[10],
[100],
],
10,
],
[
[
['"text with quotes"'],
[2],
],
'="text with quotes"',
[
[10],
[100],
],
10,
],
[
[
['"text with quotes"'],
[''],
],
'>"', // Compare to the single characater " (double quote)
[
[10],
[100],
],
10,
],
[
[
[''],
['anything'],
],
'>"', // Compare to the single characater " (double quote)
[
[10],
[100],
],
100,
],
];
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
}