2012-07-31 20:56:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
require_once 'testDataFileIterator.php';
|
|
|
|
|
|
|
|
class LogicalTest 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');
|
2015-01-23 23:44:32 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testTRUE()
|
|
|
|
{
|
|
|
|
$result = PHPExcel_Calculation_Logical::TRUE();
|
|
|
|
$this->assertEquals(true, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testFALSE()
|
|
|
|
{
|
|
|
|
$result = PHPExcel_Calculation_Logical::FALSE();
|
|
|
|
$this->assertEquals(false, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerAND
|
|
|
|
*/
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testAND()
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2015-05-17 16:34:30 +00:00
|
|
|
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'), $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerAND()
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data');
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerOR
|
|
|
|
*/
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testOR()
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2015-05-17 16:34:30 +00:00
|
|
|
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'), $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerOR()
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data');
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerNOT
|
|
|
|
*/
|
|
|
|
public function testNOT()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2015-05-17 16:34:30 +00:00
|
|
|
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'), $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerNOT()
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data');
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerIF
|
|
|
|
*/
|
|
|
|
public function testIF()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2015-05-17 16:34:30 +00:00
|
|
|
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'), $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerIF()
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data');
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerIFERROR
|
|
|
|
*/
|
|
|
|
public function testIFERROR()
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$args = func_get_args();
|
|
|
|
$expectedResult = array_pop($args);
|
2015-05-17 16:34:30 +00:00
|
|
|
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'), $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerIFERROR()
|
|
|
|
{
|
|
|
|
return new testDataFileIterator('rawTestData/Calculation/Logical/IFERROR.data');
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|