2012-07-31 20:56:11 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
2012-07-31 20:56:11 +00:00
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Logical;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2016-03-22 14:35:50 +00:00
|
|
|
class LogicalTest extends \PHPUnit_Framework_TestCase
|
2012-07-31 20:56:11 +00:00
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
Functions::setCompatibilityMode(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-08-14 04:08:43 +00:00
|
|
|
$result = Logical::TRUE();
|
2016-08-16 15:33:57 +00:00
|
|
|
$this->assertTrue($result);
|
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 testFALSE()
|
|
|
|
{
|
2016-08-14 04:08:43 +00:00
|
|
|
$result = Logical::FALSE();
|
2016-08-16 15:33:57 +00:00
|
|
|
$this->assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
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-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Logical::class, 'logicalAnd'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerAND()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Logical/AND.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
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-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Logical::class, 'logicalOr'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerOR()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Logical/OR.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
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-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Logical::class, '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()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Logical/NOT.php';
|
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-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Logical::class, 'statementIf'], $args);
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
|
|
|
|
public function providerIF()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Logical/IF.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
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-08-16 15:33:57 +00:00
|
|
|
$result = call_user_func_array([Logical::class, '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()
|
|
|
|
{
|
2016-08-16 12:00:19 +00:00
|
|
|
return require 'data/Calculation/Logical/IFERROR.php';
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-07-31 20:56:11 +00:00
|
|
|
}
|