PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php

108 lines
2.4 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
2012-07-31 20:56:11 +00:00
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Logical;
use PHPUnit\Framework\TestCase;
class LogicalTest extends TestCase
2012-07-31 20:56:11 +00:00
{
public function setUp()
{
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()
{
$result = Logical::TRUE();
self::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()
{
$result = Logical::FALSE();
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerAND
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testAND($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Logical::logicalAnd(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerAND()
{
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
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testOR($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Logical::logicalOr(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerOR()
{
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
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testNOT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Logical::NOT(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerNOT()
{
return require 'data/Calculation/Logical/NOT.php';
2012-07-31 20:56:11 +00:00
}
/**
* @dataProvider providerIF
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIF($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Logical::statementIf(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerIF()
{
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
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIFERROR($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Logical::IFERROR(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerIFERROR()
{
return require 'data/Calculation/Logical/IFERROR.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
}