No Description

FunctionsTest.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class FunctionsTest 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. public function testDUMMY()
  15. {
  16. $result = PHPExcel_Calculation_Functions::DUMMY();
  17. $this->assertEquals('#Not Yet Implemented', $result);
  18. }
  19. public function testDIV0()
  20. {
  21. $result = PHPExcel_Calculation_Functions::DIV0();
  22. $this->assertEquals('#DIV/0!', $result);
  23. }
  24. public function testNA()
  25. {
  26. $result = PHPExcel_Calculation_Functions::NA();
  27. $this->assertEquals('#N/A', $result);
  28. }
  29. public function testNaN()
  30. {
  31. $result = PHPExcel_Calculation_Functions::NaN();
  32. $this->assertEquals('#NUM!', $result);
  33. }
  34. public function testNAME()
  35. {
  36. $result = PHPExcel_Calculation_Functions::NAME();
  37. $this->assertEquals('#NAME?', $result);
  38. }
  39. public function testREF()
  40. {
  41. $result = PHPExcel_Calculation_Functions::REF();
  42. $this->assertEquals('#REF!', $result);
  43. }
  44. public function testNULL()
  45. {
  46. $result = PHPExcel_Calculation_Functions::NULL();
  47. $this->assertEquals('#NULL!', $result);
  48. }
  49. public function testVALUE()
  50. {
  51. $result = PHPExcel_Calculation_Functions::VALUE();
  52. $this->assertEquals('#VALUE!', $result);
  53. }
  54. /**
  55. * @dataProvider providerIS_BLANK
  56. */
  57. public function testIS_BLANK()
  58. {
  59. $args = func_get_args();
  60. $expectedResult = array_pop($args);
  61. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'),$args);
  62. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  63. }
  64. public function providerIS_BLANK()
  65. {
  66. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data');
  67. }
  68. /**
  69. * @dataProvider providerIS_ERR
  70. */
  71. public function testIS_ERR()
  72. {
  73. $args = func_get_args();
  74. $expectedResult = array_pop($args);
  75. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'),$args);
  76. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  77. }
  78. public function providerIS_ERR()
  79. {
  80. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data');
  81. }
  82. /**
  83. * @dataProvider providerIS_ERROR
  84. */
  85. public function testIS_ERROR()
  86. {
  87. $args = func_get_args();
  88. $expectedResult = array_pop($args);
  89. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'),$args);
  90. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  91. }
  92. public function providerIS_ERROR()
  93. {
  94. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data');
  95. }
  96. /**
  97. * @dataProvider providerERROR_TYPE
  98. */
  99. public function testERROR_TYPE()
  100. {
  101. $args = func_get_args();
  102. $expectedResult = array_pop($args);
  103. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'),$args);
  104. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  105. }
  106. public function providerERROR_TYPE()
  107. {
  108. return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
  109. }
  110. /**
  111. * @dataProvider providerIS_LOGICAL
  112. */
  113. public function testIS_LOGICAL()
  114. {
  115. $args = func_get_args();
  116. $expectedResult = array_pop($args);
  117. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'),$args);
  118. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  119. }
  120. public function providerIS_LOGICAL()
  121. {
  122. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data');
  123. }
  124. /**
  125. * @dataProvider providerIS_NA
  126. */
  127. public function testIS_NA()
  128. {
  129. $args = func_get_args();
  130. $expectedResult = array_pop($args);
  131. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'),$args);
  132. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  133. }
  134. public function providerIS_NA()
  135. {
  136. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data');
  137. }
  138. /**
  139. * @dataProvider providerIS_NUMBER
  140. */
  141. public function testIS_NUMBER()
  142. {
  143. $args = func_get_args();
  144. $expectedResult = array_pop($args);
  145. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'),$args);
  146. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  147. }
  148. public function providerIS_NUMBER()
  149. {
  150. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data');
  151. }
  152. /**
  153. * @dataProvider providerIS_TEXT
  154. */
  155. public function testIS_TEXT()
  156. {
  157. $args = func_get_args();
  158. $expectedResult = array_pop($args);
  159. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'),$args);
  160. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  161. }
  162. public function providerIS_TEXT()
  163. {
  164. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data');
  165. }
  166. /**
  167. * @dataProvider providerIS_NONTEXT
  168. */
  169. public function testIS_NONTEXT()
  170. {
  171. $args = func_get_args();
  172. $expectedResult = array_pop($args);
  173. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'),$args);
  174. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  175. }
  176. public function providerIS_NONTEXT()
  177. {
  178. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data');
  179. }
  180. /**
  181. * @dataProvider providerIS_EVEN
  182. */
  183. public function testIS_EVEN()
  184. {
  185. $args = func_get_args();
  186. $expectedResult = array_pop($args);
  187. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'),$args);
  188. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  189. }
  190. public function providerIS_EVEN()
  191. {
  192. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data');
  193. }
  194. /**
  195. * @dataProvider providerIS_ODD
  196. */
  197. public function testIS_ODD()
  198. {
  199. $args = func_get_args();
  200. $expectedResult = array_pop($args);
  201. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'),$args);
  202. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  203. }
  204. public function providerIS_ODD()
  205. {
  206. return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data');
  207. }
  208. /**
  209. * @dataProvider providerTYPE
  210. */
  211. public function testTYPE()
  212. {
  213. $args = func_get_args();
  214. $expectedResult = array_pop($args);
  215. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'),$args);
  216. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  217. }
  218. public function providerTYPE()
  219. {
  220. return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data');
  221. }
  222. /**
  223. * @dataProvider providerN
  224. */
  225. public function testN()
  226. {
  227. $args = func_get_args();
  228. $expectedResult = array_pop($args);
  229. $result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'),$args);
  230. $this->assertEquals($expectedResult, $result, NULL, 1E-8);
  231. }
  232. public function providerN()
  233. {
  234. return new testDataFileIterator('rawTestData/Calculation/Functions/N.data');
  235. }
  236. }