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

515 lines
15 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
require_once 'testDataFileIterator.php';
class FinancialTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
2015-05-17 16:34:30 +00:00
if (!defined('PHPEXCEL_ROOT')) {
2012-07-31 20:56:11 +00:00
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
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerACCRINT
*/
2015-05-17 13:00:02 +00:00
public function testACCRINT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINT'), $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 providerACCRINT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerACCRINTM
*/
2015-05-17 13:00:02 +00:00
public function testACCRINTM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINTM'), $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 providerACCRINTM()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINTM.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerAMORDEGRC
*/
2015-05-17 13:00:02 +00:00
public function testAMORDEGRC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORDEGRC'), $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 providerAMORDEGRC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/AMORDEGRC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerAMORLINC
*/
2015-05-17 13:00:02 +00:00
public function testAMORLINC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORLINC'), $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 providerAMORLINC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/AMORLINC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPDAYBS
*/
2015-05-17 13:00:02 +00:00
public function testCOUPDAYBS()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYBS'), $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 providerCOUPDAYBS()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYBS.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPDAYS
*/
2015-05-17 13:00:02 +00:00
public function testCOUPDAYS()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYS'), $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 providerCOUPDAYS()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYS.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPDAYSNC
*/
2015-05-17 13:00:02 +00:00
public function testCOUPDAYSNC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYSNC'), $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 providerCOUPDAYSNC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYSNC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPNCD
*/
2015-05-17 13:00:02 +00:00
public function testCOUPNCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNCD'), $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 providerCOUPNCD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNCD.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPNUM
*/
2015-05-17 13:00:02 +00:00
public function testCOUPNUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNUM'), $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 providerCOUPNUM()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNUM.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOUPPCD
*/
2015-05-17 13:00:02 +00:00
public function testCOUPPCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPPCD'), $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 providerCOUPPCD()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/COUPPCD.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCUMIPMT
*/
2015-05-17 13:00:02 +00:00
public function testCUMIPMT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMIPMT'), $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 providerCUMIPMT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/CUMIPMT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCUMPRINC
*/
2015-05-17 13:00:02 +00:00
public function testCUMPRINC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMPRINC'), $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 providerCUMPRINC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/CUMPRINC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerDB
*/
2015-05-17 13:00:02 +00:00
public function testDB()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','DB'), $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 providerDB()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/DB.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerDDB
*/
2015-05-17 13:00:02 +00:00
public function testDDB()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','DDB'), $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 providerDDB()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/DDB.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerDISC
*/
2015-05-17 13:00:02 +00:00
public function testDISC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','DISC'), $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 providerDISC()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/DISC.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerDOLLARDE
*/
2015-05-17 13:00:02 +00:00
public function testDOLLARDE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARDE'), $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 providerDOLLARDE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARDE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerDOLLARFR
*/
2015-05-17 13:00:02 +00:00
public function testDOLLARFR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARFR'), $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 providerDOLLARFR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARFR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerEFFECT
*/
2015-05-17 13:00:02 +00:00
public function testEFFECT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','EFFECT'), $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 providerEFFECT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/EFFECT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFV
*/
2015-05-17 13:00:02 +00:00
public function testFV()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','FV'), $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 providerFV()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/FV.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFVSCHEDULE
*/
2015-05-17 13:00:02 +00:00
public function testFVSCHEDULE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','FVSCHEDULE'), $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 providerFVSCHEDULE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/FVSCHEDULE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerINTRATE
*/
2015-05-17 13:00:02 +00:00
public function testINTRATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','INTRATE'), $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 providerINTRATE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/INTRATE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIPMT
*/
2015-05-17 13:00:02 +00:00
public function testIPMT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','IPMT'), $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 providerIPMT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/IPMT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerIRR
*/
2015-05-17 13:00:02 +00:00
public function testIRR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','IRR'), $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 providerIRR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/IRR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerISPMT
*/
2015-05-17 13:00:02 +00:00
public function testISPMT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','ISPMT'), $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 providerISPMT()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/ISPMT.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMIRR
*/
2015-05-17 13:00:02 +00:00
public function testMIRR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','MIRR'), $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 providerMIRR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/MIRR.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerNOMINAL
*/
2015-05-17 13:00:02 +00:00
public function testNOMINAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','NOMINAL'), $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 providerNOMINAL()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/NOMINAL.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerNPER
*/
2015-05-17 13:00:02 +00:00
public function testNPER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPER'), $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 providerNPER()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/NPER.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerNPV
*/
2015-05-17 13:00:02 +00:00
public function testNPV()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPV'), $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 providerNPV()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/NPV.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPRICE
*/
2015-05-17 13:00:02 +00:00
public function testPRICE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','PRICE'), $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 providerPRICE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/PRICE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerRATE
*/
2015-05-17 13:00:02 +00:00
public function testRATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','RATE'), $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 providerRATE()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/RATE.data');
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerXIRR
*/
2015-05-17 13:00:02 +00:00
public function testXIRR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +00:00
$result = call_user_func_array(array('PHPExcel_Calculation_Financial','XIRR'), $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 providerXIRR()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Calculation/Financial/XIRR.data');
}
2012-07-31 20:56:11 +00:00
}