PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php

124 lines
2.7 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
Add further new Functions introduced in MS Excel 2013 and 2016 (#608) - Fix ISFORMULA() function to work with a cell reference to another worksheet - Added calculation engine support for the new functions that were added in MS Excel 2013 and MS Excel 2016 - Text Functions - CONCAT() Synonym for CONCATENATE() - NUMBERVALUE() Converts text to a number, in a locale-independent way - UNICHAR() Synonym for CHAR() in PHPSpreadsheet, which has always used UTF-8 internally - UNIORD() Synonym for ORD() in PHPSpreadsheet, which has always used UTF-8 internally - TEXTJOIN() Joins together two or more text strings, separated by a delimiter - Logical Functions - XOR() Returns a logical Exclusive Or of all arguments - Date/Time Functions - ISOWEEKNUM() Returns the ISO 8601 week number of the year for a given date - Lookup and Reference Functions - FORMULATEXT() Returns a formula as a string - Engineering Functions - ERF.PRECISE() Returns the error function integrated between 0 and a supplied limit - ERFC.PRECISE() Synonym for ERFC - Math and Trig Functions - SEC() Returns the secant of an angle - SECH() Returns the hyperbolic secant of an angle - CSC() Returns the cosecant of an angle - CSCH() Returns the hyperbolic cosecant of an angle - COT() Returns the cotangent of an angle - COTH() Returns the hyperbolic cotangent of an angle - ACOT() Returns the cotangent of an angle - ACOTH() Returns the hyperbolic cotangent of an angle - Financial Functions - PDURATION() Calculates the number of periods required for an investment to reach a specified value - RRI() Calculates the interest rate required for an investment to grow to a specified future value
2018-07-22 18:17:04 +00:00
/**
* @dataProvider providerXOR
*
* @param mixed $expectedResult
*/
public function testXOR($expectedResult, ...$args)
{
$result = Logical::logicalXor(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerXOR()
{
return require 'data/Calculation/Logical/XOR.php';
}
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
}