No Description

LogicalTest.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class LogicalTest 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 testTRUE()
  15. {
  16. $result = PHPExcel_Calculation_Logical::TRUE();
  17. $this->assertEquals(TRUE, $result);
  18. }
  19. public function testFALSE()
  20. {
  21. $result = PHPExcel_Calculation_Logical::FALSE();
  22. $this->assertEquals(FALSE, $result);
  23. }
  24. /**
  25. * @dataProvider providerAND
  26. */
  27. public function testAND()
  28. {
  29. $args = func_get_args();
  30. $expectedResult = array_pop($args);
  31. $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'),$args);
  32. $this->assertEquals($expectedResult, $result);
  33. }
  34. public function providerAND()
  35. {
  36. return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data');
  37. }
  38. /**
  39. * @dataProvider providerOR
  40. */
  41. public function testOR()
  42. {
  43. $args = func_get_args();
  44. $expectedResult = array_pop($args);
  45. $result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'),$args);
  46. $this->assertEquals($expectedResult, $result);
  47. }
  48. public function providerOR()
  49. {
  50. return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data');
  51. }
  52. /**
  53. * @dataProvider providerNOT
  54. */
  55. public function testNOT()
  56. {
  57. $args = func_get_args();
  58. $expectedResult = array_pop($args);
  59. $result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'),$args);
  60. $this->assertEquals($expectedResult, $result);
  61. }
  62. public function providerNOT()
  63. {
  64. return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data');
  65. }
  66. /**
  67. * @dataProvider providerIF
  68. */
  69. public function testIF()
  70. {
  71. $args = func_get_args();
  72. $expectedResult = array_pop($args);
  73. $result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'),$args);
  74. $this->assertEquals($expectedResult, $result);
  75. }
  76. public function providerIF()
  77. {
  78. return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data');
  79. }
  80. /**
  81. * @dataProvider providerIFERROR
  82. */
  83. public function testIFERROR()
  84. {
  85. $args = func_get_args();
  86. $expectedResult = array_pop($args);
  87. $result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'),$args);
  88. $this->assertEquals($expectedResult, $result);
  89. }
  90. public function providerIFERROR()
  91. {
  92. return new testDataFileIterator('rawTestData/Calculation/Logical/IFERROR.data');
  93. }
  94. }