No Description

CalculationTest.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class CalculationTest extends PHPUnit_Framework_TestCase
  4. {
  5. public function setUp()
  6. {
  7. if (!defined('PHPEXCEL_ROOT')) {
  8. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  9. }
  10. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  11. PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerBinaryComparisonOperation
  15. */
  16. public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice)
  17. {
  18. PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
  19. $resultExcel = \PHPExcel_Calculation::getInstance()->_calculateFormulaValue($formula);
  20. $this->assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible');
  21. PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE);
  22. $resultOpenOffice = \PHPExcel_Calculation::getInstance()->_calculateFormulaValue($formula);
  23. $this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible');
  24. }
  25. public function providerBinaryComparisonOperation()
  26. {
  27. return new testDataFileIterator('rawTestData/CalculationBinaryComparisonOperation.data');
  28. }
  29. }