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
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2016-03-22 14:35:50 +00:00
|
|
|
class FunctionsTest extends \PHPUnit_Framework_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
|
|
|
}
|
|
|
|
|
|
|
|
public function testDUMMY()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::DUMMY();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#Not Yet Implemented', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDIV0()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::DIV0();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#DIV/0!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNA()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::NA();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#N/A', $result);
|
|
|
|
}
|
|
|
|
|
2016-05-14 08:29:38 +00:00
|
|
|
public function testNAN()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::NAN();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NUM!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNAME()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::NAME();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NAME?', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testREF()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::REF();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#REF!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNULL()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::null();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NULL!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testVALUE()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Functions::VALUE();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#VALUE!', $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsBlank
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsBlank()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isBlank'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsBlank()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_BLANK.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsErr
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsErr()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isErr'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsErr()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_ERR.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsError
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsError()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isError'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsError()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_ERROR.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerErrorType
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testErrorType()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'errorType'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerErrorType()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/ERROR_TYPE.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsLogical
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsLogical()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isLogical'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsLogical()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_LOGICAL.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsNa
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsNa()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isNa'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsNa()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_NA.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsNumber
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsNumber()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isNumber'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsNumber()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_NUMBER.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsText
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsText()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isText'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsText()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_TEXT.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsNonText
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsNonText()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isNonText'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsNonText()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_NONTEXT.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsEven
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsEven()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isEven'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsEven()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_EVEN.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
2016-05-18 07:02:39 +00:00
|
|
|
* @dataProvider providerIsOdd
|
2012-07-31 20:56:11 +00:00
|
|
|
*/
|
2016-05-18 07:02:39 +00:00
|
|
|
public function testIsOdd()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'isOdd'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-05-18 07:02:39 +00:00
|
|
|
public function providerIsOdd()
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/IS_ODD.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTYPE
|
|
|
|
*/
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testTYPE()
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'TYPE'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerTYPE()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/TYPE.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerN
|
|
|
|
*/
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testN()
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2016-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Functions::class, 'n'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result, null, 1E-8);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerN()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Functions/N.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|