2012-07-31 20:56:11 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2017-10-29 08:39:42 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
2018-04-20 06:24:11 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
2017-11-08 15:48:01 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2017-11-08 15:48:01 +00:00
|
|
|
class MathTrigTest extends TestCase
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerATAN2
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testATAN2($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::ATAN2(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerATAN2()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testCEILING($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::CEILING(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerCEILING()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testCOMBIN($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::COMBIN(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerCOMBIN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testEVEN($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::EVEN(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerEVEN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testODD($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::ODD(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerODD()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testFACT($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::FACT(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerFACT()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testFACTDOUBLE($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::FACTDOUBLE(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerFACTDOUBLE()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testFLOOR($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::FLOOR(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerFLOOR()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testGCD($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::GCD(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerGCD()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testLCM($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::LCM(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerLCM()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testINT($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::INT(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerINT()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testSIGN($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::SIGN(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerSIGN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testPOWER($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::POWER(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerPOWER()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testLOG($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::logBase(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerLOG()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMOD($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MOD(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMOD()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMDETERM($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MDETERM(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMDETERM()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMINVERSE($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2016-08-14 04:32:43 +00:00
|
|
|
$this->markTestIncomplete('TODO: This test should be fixed');
|
|
|
|
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MINVERSE(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMINVERSE()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMMULT($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2016-08-14 04:32:43 +00:00
|
|
|
$this->markTestIncomplete('TODO: This test should be fixed');
|
|
|
|
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MMULT(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMMULT()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMULTINOMIAL($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MULTINOMIAL(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMULTINOMIAL()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testMROUND($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::MROUND(...$args);
|
2016-08-14 04:08:43 +00:00
|
|
|
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerMROUND()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testPRODUCT($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::PRODUCT(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerPRODUCT()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testQUOTIENT($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::QUOTIENT(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerQUOTIENT()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testROUNDUP($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::ROUNDUP(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerROUNDUP()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testROUNDDOWN($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::ROUNDDOWN(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerROUNDDOWN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testSERIESSUM($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::SERIESSUM(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerSERIESSUM()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testSUMSQ($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::SUMSQ(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerSUMSQ()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testTRUNC($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::TRUNC(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerTRUNC()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testROMAN($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::ROMAN(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerROMAN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
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
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testSQRTPI($expectedResult, ...$args)
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::SQRTPI(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerSQRTPI()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/MathTrig/SQRTPI.php';
|
2013-08-08 03:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerSUMIF
|
2017-01-23 05:49:10 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
2013-08-08 03:17:00 +00:00
|
|
|
*/
|
2017-01-23 05:49:10 +00:00
|
|
|
public function testSUMIF($expectedResult, ...$args)
|
2013-08-08 03:17:00 +00:00
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
$result = MathTrig::SUMIF(...$args);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
2013-08-08 03:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerSUMIF()
|
|
|
|
{
|
2017-01-23 05:49:10 +00:00
|
|
|
return require 'data/Calculation/MathTrig/SUMIF.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2018-04-19 21:44:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerSUBTOTAL
|
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
|
|
|
*/
|
|
|
|
public function testSUBTOTAL($expectedResult, ...$args)
|
|
|
|
{
|
2018-04-20 06:24:11 +00:00
|
|
|
$cell = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getValue'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cell->method('getValue')
|
|
|
|
->willReturn(null);
|
|
|
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
|
|
|
->setMethods(['cellExists', 'getCell'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$worksheet->method('cellExists')
|
|
|
|
->willReturn(true);
|
|
|
|
$worksheet->method('getCell')
|
|
|
|
->willReturn($cell);
|
|
|
|
$cellReference = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getWorksheet'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cellReference->method('getWorksheet')
|
|
|
|
->willReturn($worksheet);
|
2018-04-19 21:44:23 +00:00
|
|
|
|
|
|
|
array_push($args, $cellReference);
|
|
|
|
$result = MathTrig::SUBTOTAL(...$args);
|
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function providerSUBTOTAL()
|
|
|
|
{
|
|
|
|
return require 'data/Calculation/MathTrig/SUBTOTAL.php';
|
|
|
|
}
|
2018-04-20 06:24:11 +00:00
|
|
|
|
|
|
|
protected static function rowVisibility() {
|
|
|
|
yield from [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 =>true];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-21 00:33:26 +00:00
|
|
|
* @dataProvider providerHiddenSUBTOTAL
|
2018-04-20 06:24:11 +00:00
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
|
|
|
*/
|
2018-04-21 00:33:26 +00:00
|
|
|
public function testHiddenSUBTOTAL($expectedResult, ...$args)
|
2018-04-20 06:24:11 +00:00
|
|
|
{
|
|
|
|
$generator = \PhpOffice\PhpSpreadsheetTests\Calculation\MathTrigTest::rowVisibility();
|
|
|
|
$rowDimension = $this->getMockBuilder(RowDimension::class)
|
|
|
|
->setMethods(['getVisible'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$rowDimension->method('getVisible')
|
|
|
|
->will($this->returnCallback(function() use ($generator) { $result = $generator->current(); $generator->next(); return $result; }));
|
|
|
|
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
|
|
|
->setMethods(['getVisible'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$columnDimension->method('getVisible')
|
|
|
|
->willReturn(true);
|
|
|
|
$cell = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getValue'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cell->method('getValue')
|
|
|
|
->willReturn('');
|
|
|
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
|
|
|
->setMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$worksheet->method('cellExists')
|
|
|
|
->willReturn(true);
|
|
|
|
$worksheet->method('getCell')
|
|
|
|
->willReturn($cell);
|
|
|
|
$worksheet->method('getRowDimension')
|
|
|
|
->willReturn($rowDimension);
|
|
|
|
$worksheet->method('getColumnDimension')
|
|
|
|
->willReturn($columnDimension);
|
|
|
|
$cellReference = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getWorksheet'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cellReference->method('getWorksheet')
|
|
|
|
->willReturn($worksheet);
|
|
|
|
|
|
|
|
array_push($args, $cellReference);
|
|
|
|
$result = MathTrig::SUBTOTAL(...$args);
|
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
|
|
|
}
|
|
|
|
|
2018-04-21 00:33:26 +00:00
|
|
|
public function providerHiddenSUBTOTAL()
|
2018-04-20 06:24:11 +00:00
|
|
|
{
|
|
|
|
return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
|
|
|
|
}
|
2018-04-21 00:33:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerNestedSUBTOTAL
|
|
|
|
*
|
|
|
|
* @param mixed $expectedResult
|
|
|
|
*/
|
|
|
|
public function testNestedSUBTOTAL($expectedResult, ...$args)
|
|
|
|
{
|
|
|
|
$cell = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getValue'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cell->method('getValue')
|
|
|
|
->willReturn(null);
|
|
|
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
|
|
|
->setMethods(['cellExists', 'getCell'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$worksheet->method('cellExists')
|
|
|
|
->willReturn(true);
|
|
|
|
$worksheet->method('getCell')
|
|
|
|
->willReturn($cell);
|
|
|
|
$cellReference = $this->getMockBuilder(Cell::class)
|
|
|
|
->setMethods(['getWorksheet'])
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$cellReference->method('getWorksheet')
|
|
|
|
->willReturn($worksheet);
|
|
|
|
|
|
|
|
array_push($args, $cellReference);
|
|
|
|
$result = MathTrig::SUBTOTAL(...$args);
|
|
|
|
self::assertEquals($expectedResult, $result, null, 1E-12);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function providerNestedSUBTOTAL()
|
|
|
|
{
|
|
|
|
return require 'data/Calculation/MathTrig/SUBTOTALNESTED.php';
|
|
|
|
}
|
|
|
|
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|