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

277 lines
7.8 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()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
2015-05-17 13:00:02 +00:00
}
public function testDUMMY()
{
$result = PHPExcel_Calculation_Functions::DUMMY();
$this->assertEquals('#Not Yet Implemented', $result);
}
public function testDIV0()
{
$result = PHPExcel_Calculation_Functions::DIV0();
$this->assertEquals('#DIV/0!', $result);
}
public function testNA()
{
$result = PHPExcel_Calculation_Functions::NA();
$this->assertEquals('#N/A', $result);
}
public function testNaN()
{
$result = PHPExcel_Calculation_Functions::NaN();
$this->assertEquals('#NUM!', $result);
}
public function testNAME()
{
$result = PHPExcel_Calculation_Functions::NAME();
$this->assertEquals('#NAME?', $result);
}
public function testREF()
{
$result = PHPExcel_Calculation_Functions::REF();
$this->assertEquals('#REF!', $result);
}
public function testNULL()
{
$result = PHPExcel_Calculation_Functions::null();
$this->assertEquals('#NULL!', $result);
}
public function testVALUE()
{
$result = PHPExcel_Calculation_Functions::VALUE();
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'),$args);
$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);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'),$args);
$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
}