PhpSpreadsheet/unitTests/Classes/src/Calculation/FunctionsTest.php

270 lines
7.6 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
require_once 'testDataFileIterator.php';
class FunctionsTest extends PHPUnit_Framework_TestCase
{
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);
}
public function testNaN()
{
2016-03-22 14:19:00 +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
/**
* @dataProvider providerIS_BLANK
*/
2015-05-17 13:00:02 +00:00
public function testIS_BLANK()
{
$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','IS_BLANK'), $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 providerIS_BLANK()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_ERR
*/
2015-05-17 13:00:02 +00:00
public function testIS_ERR()
{
$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','IS_ERR'), $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 providerIS_ERR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_ERROR
*/
2015-05-17 13:00:02 +00:00
public function testIS_ERROR()
{
$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','IS_ERROR'), $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 providerIS_ERROR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerERROR_TYPE
*/
2015-05-17 13:00:02 +00:00
public function testERROR_TYPE()
{
$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','ERROR_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 providerERROR_TYPE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_LOGICAL
*/
2015-05-17 13:00:02 +00:00
public function testIS_LOGICAL()
{
$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','IS_LOGICAL'), $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 providerIS_LOGICAL()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_NA
*/
2015-05-17 13:00:02 +00:00
public function testIS_NA()
{
$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','IS_NA'), $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 providerIS_NA()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_NUMBER
*/
2015-05-17 13:00:02 +00:00
public function testIS_NUMBER()
{
$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','IS_NUMBER'), $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 providerIS_NUMBER()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_TEXT
*/
2015-05-17 13:00:02 +00:00
public function testIS_TEXT()
{
$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','IS_TEXT'), $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 providerIS_TEXT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_NONTEXT
*/
2015-05-17 13:00:02 +00:00
public function testIS_NONTEXT()
{
$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','IS_NONTEXT'), $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 providerIS_NONTEXT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_EVEN
*/
2015-05-17 13:00:02 +00:00
public function testIS_EVEN()
{
$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','IS_EVEN'), $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 providerIS_EVEN()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIS_ODD
*/
2015-05-17 13:00:02 +00:00
public function testIS_ODD()
{
$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','IS_ODD'), $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 providerIS_ODD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data');
}
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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data');
}
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-03-22 14:19:00 +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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Functions/N.data');
}
2012-07-31 20:56:11 +00:00
}