PhpSpreadsheet/unitTests/Classes/src/Calculation/LogicalTest.php

106 lines
2.8 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
require_once 'testDataFileIterator.php';
class LogicalTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
2016-03-22 14:19:00 +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()
{
2016-03-22 14:19:00 +00:00
$result = \PHPExcel\Calculation\Logical::TRUE();
2015-05-17 13:00:02 +00:00
$this->assertEquals(true, $result);
}
2012-07-31 20:56:11 +00:00
2015-05-17 13:00:02 +00:00
public function testFALSE()
{
2016-03-22 14:19:00 +00:00
$result = \PHPExcel\Calculation\Logical::FALSE();
2015-05-17 13:00:02 +00:00
$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);
2016-03-22 14:19:00 +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);
2016-03-22 14:19:00 +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);
2016-03-22 14:19:00 +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);
2016-03-22 14:19:00 +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);
2016-03-22 14:19:00 +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
}