No Description

FinancialTest.php 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class FinancialTest extends PHPUnit_Framework_TestCase
  4. {
  5. public function setUp()
  6. {
  7. if (!defined('PHPEXCEL_ROOT'))
  8. {
  9. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  10. }
  11. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  12. PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
  13. }
  14. /**
  15. * @dataProvider providerACCRINT
  16. */
  17. public function testACCRINT()
  18. {
  19. $args = func_get_args();
  20. $expectedResult = array_pop($args);
  21. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINT'),$args);
  22. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  23. }
  24. public function providerACCRINT()
  25. {
  26. return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINT.data');
  27. }
  28. /**
  29. * @dataProvider providerACCRINTM
  30. */
  31. public function testACCRINTM()
  32. {
  33. $args = func_get_args();
  34. $expectedResult = array_pop($args);
  35. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ACCRINTM'),$args);
  36. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  37. }
  38. public function providerACCRINTM()
  39. {
  40. return new testDataFileIterator('rawTestData/Calculation/Financial/ACCRINTM.data');
  41. }
  42. /**
  43. * @dataProvider providerAMORDEGRC
  44. */
  45. public function testAMORDEGRC()
  46. {
  47. $args = func_get_args();
  48. $expectedResult = array_pop($args);
  49. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORDEGRC'),$args);
  50. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  51. }
  52. public function providerAMORDEGRC()
  53. {
  54. return new testDataFileIterator('rawTestData/Calculation/Financial/AMORDEGRC.data');
  55. }
  56. /**
  57. * @dataProvider providerAMORLINC
  58. */
  59. public function testAMORLINC()
  60. {
  61. $args = func_get_args();
  62. $expectedResult = array_pop($args);
  63. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','AMORLINC'),$args);
  64. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  65. }
  66. public function providerAMORLINC()
  67. {
  68. return new testDataFileIterator('rawTestData/Calculation/Financial/AMORLINC.data');
  69. }
  70. /**
  71. * @dataProvider providerCOUPDAYBS
  72. */
  73. public function testCOUPDAYBS()
  74. {
  75. $args = func_get_args();
  76. $expectedResult = array_pop($args);
  77. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYBS'),$args);
  78. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  79. }
  80. public function providerCOUPDAYBS()
  81. {
  82. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYBS.data');
  83. }
  84. /**
  85. * @dataProvider providerCOUPDAYS
  86. */
  87. public function testCOUPDAYS()
  88. {
  89. $args = func_get_args();
  90. $expectedResult = array_pop($args);
  91. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYS'),$args);
  92. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  93. }
  94. public function providerCOUPDAYS()
  95. {
  96. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYS.data');
  97. }
  98. /**
  99. * @dataProvider providerCOUPDAYSNC
  100. */
  101. public function testCOUPDAYSNC()
  102. {
  103. $args = func_get_args();
  104. $expectedResult = array_pop($args);
  105. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPDAYSNC'),$args);
  106. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  107. }
  108. public function providerCOUPDAYSNC()
  109. {
  110. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPDAYSNC.data');
  111. }
  112. /**
  113. * @dataProvider providerCOUPNCD
  114. */
  115. public function testCOUPNCD()
  116. {
  117. $args = func_get_args();
  118. $expectedResult = array_pop($args);
  119. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNCD'),$args);
  120. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  121. }
  122. public function providerCOUPNCD()
  123. {
  124. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNCD.data');
  125. }
  126. /**
  127. * @dataProvider providerCOUPNUM
  128. */
  129. public function testCOUPNUM()
  130. {
  131. $args = func_get_args();
  132. $expectedResult = array_pop($args);
  133. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPNUM'),$args);
  134. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  135. }
  136. public function providerCOUPNUM()
  137. {
  138. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPNUM.data');
  139. }
  140. /**
  141. * @dataProvider providerCOUPPCD
  142. */
  143. public function testCOUPPCD()
  144. {
  145. $args = func_get_args();
  146. $expectedResult = array_pop($args);
  147. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','COUPPCD'),$args);
  148. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  149. }
  150. public function providerCOUPPCD()
  151. {
  152. return new testDataFileIterator('rawTestData/Calculation/Financial/COUPPCD.data');
  153. }
  154. /**
  155. * @dataProvider providerCUMIPMT
  156. */
  157. public function testCUMIPMT()
  158. {
  159. $args = func_get_args();
  160. $expectedResult = array_pop($args);
  161. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMIPMT'),$args);
  162. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  163. }
  164. public function providerCUMIPMT()
  165. {
  166. return new testDataFileIterator('rawTestData/Calculation/Financial/CUMIPMT.data');
  167. }
  168. /**
  169. * @dataProvider providerCUMPRINC
  170. */
  171. public function testCUMPRINC()
  172. {
  173. $args = func_get_args();
  174. $expectedResult = array_pop($args);
  175. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','CUMPRINC'),$args);
  176. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  177. }
  178. public function providerCUMPRINC()
  179. {
  180. return new testDataFileIterator('rawTestData/Calculation/Financial/CUMPRINC.data');
  181. }
  182. /**
  183. * @dataProvider providerDB
  184. */
  185. public function testDB()
  186. {
  187. $args = func_get_args();
  188. $expectedResult = array_pop($args);
  189. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DB'),$args);
  190. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  191. }
  192. public function providerDB()
  193. {
  194. return new testDataFileIterator('rawTestData/Calculation/Financial/DB.data');
  195. }
  196. /**
  197. * @dataProvider providerDDB
  198. */
  199. public function testDDB()
  200. {
  201. $args = func_get_args();
  202. $expectedResult = array_pop($args);
  203. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DDB'),$args);
  204. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  205. }
  206. public function providerDDB()
  207. {
  208. return new testDataFileIterator('rawTestData/Calculation/Financial/DDB.data');
  209. }
  210. /**
  211. * @dataProvider providerDISC
  212. */
  213. public function testDISC()
  214. {
  215. $args = func_get_args();
  216. $expectedResult = array_pop($args);
  217. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DISC'),$args);
  218. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  219. }
  220. public function providerDISC()
  221. {
  222. return new testDataFileIterator('rawTestData/Calculation/Financial/DISC.data');
  223. }
  224. /**
  225. * @dataProvider providerDOLLARDE
  226. */
  227. public function testDOLLARDE()
  228. {
  229. $args = func_get_args();
  230. $expectedResult = array_pop($args);
  231. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARDE'),$args);
  232. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  233. }
  234. public function providerDOLLARDE()
  235. {
  236. return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARDE.data');
  237. }
  238. /**
  239. * @dataProvider providerDOLLARFR
  240. */
  241. public function testDOLLARFR()
  242. {
  243. $args = func_get_args();
  244. $expectedResult = array_pop($args);
  245. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','DOLLARFR'),$args);
  246. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  247. }
  248. public function providerDOLLARFR()
  249. {
  250. return new testDataFileIterator('rawTestData/Calculation/Financial/DOLLARFR.data');
  251. }
  252. /**
  253. * @dataProvider providerEFFECT
  254. */
  255. public function testEFFECT()
  256. {
  257. $args = func_get_args();
  258. $expectedResult = array_pop($args);
  259. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','EFFECT'),$args);
  260. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  261. }
  262. public function providerEFFECT()
  263. {
  264. return new testDataFileIterator('rawTestData/Calculation/Financial/EFFECT.data');
  265. }
  266. /**
  267. * @dataProvider providerFV
  268. */
  269. public function testFV()
  270. {
  271. $args = func_get_args();
  272. $expectedResult = array_pop($args);
  273. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FV'),$args);
  274. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  275. }
  276. public function providerFV()
  277. {
  278. return new testDataFileIterator('rawTestData/Calculation/Financial/FV.data');
  279. }
  280. /**
  281. * @dataProvider providerFVSCHEDULE
  282. */
  283. public function testFVSCHEDULE()
  284. {
  285. $args = func_get_args();
  286. $expectedResult = array_pop($args);
  287. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','FVSCHEDULE'),$args);
  288. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  289. }
  290. public function providerFVSCHEDULE()
  291. {
  292. return new testDataFileIterator('rawTestData/Calculation/Financial/FVSCHEDULE.data');
  293. }
  294. /**
  295. * @dataProvider providerINTRATE
  296. */
  297. public function testINTRATE()
  298. {
  299. $args = func_get_args();
  300. $expectedResult = array_pop($args);
  301. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','INTRATE'),$args);
  302. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  303. }
  304. public function providerINTRATE()
  305. {
  306. return new testDataFileIterator('rawTestData/Calculation/Financial/INTRATE.data');
  307. }
  308. /**
  309. * @dataProvider providerIPMT
  310. */
  311. public function testIPMT()
  312. {
  313. $args = func_get_args();
  314. $expectedResult = array_pop($args);
  315. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IPMT'),$args);
  316. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  317. }
  318. public function providerIPMT()
  319. {
  320. return new testDataFileIterator('rawTestData/Calculation/Financial/IPMT.data');
  321. }
  322. /**
  323. * @dataProvider providerIRR
  324. */
  325. public function testIRR()
  326. {
  327. $args = func_get_args();
  328. $expectedResult = array_pop($args);
  329. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','IRR'),$args);
  330. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  331. }
  332. public function providerIRR()
  333. {
  334. return new testDataFileIterator('rawTestData/Calculation/Financial/IRR.data');
  335. }
  336. /**
  337. * @dataProvider providerISPMT
  338. */
  339. public function testISPMT()
  340. {
  341. $args = func_get_args();
  342. $expectedResult = array_pop($args);
  343. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','ISPMT'),$args);
  344. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  345. }
  346. public function providerISPMT()
  347. {
  348. return new testDataFileIterator('rawTestData/Calculation/Financial/ISPMT.data');
  349. }
  350. /**
  351. * @dataProvider providerMIRR
  352. */
  353. public function testMIRR()
  354. {
  355. $args = func_get_args();
  356. $expectedResult = array_pop($args);
  357. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','MIRR'),$args);
  358. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  359. }
  360. public function providerMIRR()
  361. {
  362. return new testDataFileIterator('rawTestData/Calculation/Financial/MIRR.data');
  363. }
  364. /**
  365. * @dataProvider providerNOMINAL
  366. */
  367. public function testNOMINAL()
  368. {
  369. $args = func_get_args();
  370. $expectedResult = array_pop($args);
  371. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NOMINAL'),$args);
  372. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  373. }
  374. public function providerNOMINAL()
  375. {
  376. return new testDataFileIterator('rawTestData/Calculation/Financial/NOMINAL.data');
  377. }
  378. /**
  379. * @dataProvider providerNPER
  380. */
  381. public function testNPER()
  382. {
  383. $args = func_get_args();
  384. $expectedResult = array_pop($args);
  385. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPER'),$args);
  386. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  387. }
  388. public function providerNPER()
  389. {
  390. return new testDataFileIterator('rawTestData/Calculation/Financial/NPER.data');
  391. }
  392. /**
  393. * @dataProvider providerNPV
  394. */
  395. public function testNPV()
  396. {
  397. $args = func_get_args();
  398. $expectedResult = array_pop($args);
  399. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','NPV'),$args);
  400. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  401. }
  402. public function providerNPV()
  403. {
  404. return new testDataFileIterator('rawTestData/Calculation/Financial/NPV.data');
  405. }
  406. /**
  407. * @dataProvider providerPRICE
  408. */
  409. public function testPRICE()
  410. {
  411. $args = func_get_args();
  412. $expectedResult = array_pop($args);
  413. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','PRICE'),$args);
  414. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  415. }
  416. public function providerPRICE()
  417. {
  418. return new testDataFileIterator('rawTestData/Calculation/Financial/PRICE.data');
  419. }
  420. /**
  421. * @dataProvider providerRATE
  422. */
  423. public function testRATE()
  424. {
  425. $args = func_get_args();
  426. $expectedResult = array_pop($args);
  427. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','RATE'),$args);
  428. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  429. }
  430. public function providerRATE()
  431. {
  432. return new testDataFileIterator('rawTestData/Calculation/Financial/RATE.data');
  433. }
  434. /**
  435. * @dataProvider providerXIRR
  436. */
  437. public function testXIRR()
  438. {
  439. $args = func_get_args();
  440. $expectedResult = array_pop($args);
  441. $result = call_user_func_array(array('PHPExcel_Calculation_Financial','XIRR'),$args);
  442. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  443. }
  444. public function providerXIRR()
  445. {
  446. return new testDataFileIterator('rawTestData/Calculation/Financial/XIRR.data');
  447. }
  448. }