2012-07-31 20:56:11 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-13 17:22:11 +00:00
|
|
|
namespace PhpSpreadsheet\Tests\Calculation;
|
2012-07-31 20:56:11 +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-03-22 14:19:00 +00:00
|
|
|
\PHPExcel\Calculation\Functions::setCompatibilityMode(\PHPExcel\Calculation\Functions::COMPATIBILITY_EXCEL);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDUMMY()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::DUMMY();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#Not Yet Implemented', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDIV0()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::DIV0();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#DIV/0!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNA()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\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-05-14 08:29:38 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::NAN();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NUM!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNAME()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::NAME();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NAME?', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testREF()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::REF();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#REF!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNULL()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\Functions::null();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals('#NULL!', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testVALUE()
|
|
|
|
{
|
2016-03-22 14:19:00 +00:00
|
|
|
$result = \PHPExcel\Calculation\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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data');
|
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-05-18 07:02:39 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data');
|
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-05-18 07:02:39 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data');
|
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-05-18 11:37:00 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data');
|
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-05-14 08:29:38 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data');
|
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-03-22 14:19:00 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/TYPE.data');
|
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-05-18 07:02:39 +00:00
|
|
|
$result = call_user_func_array(array('\PHPExcel\Calculation\Functions','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-13 17:22:11 +00:00
|
|
|
return new \PhpSpreadsheet\Tests\TestDataFileIterator('rawTestData/Calculation/Functions/N.data');
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|