PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php

386 lines
10 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\Cell\Cell;
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
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PHPUnit\Framework\TestCase;
class FunctionsTest extends TestCase
2012-07-31 20:56:11 +00:00
{
2020-04-27 10:28:36 +00:00
protected function setUp(): void
2012-07-31 20:56:11 +00:00
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
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
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
}
2020-04-27 10:28:36 +00:00
protected function tearDown(): void
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
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
}
public function testCompatibilityMode()
{
$result = Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC);
// Test for a true response for success
$this->assertTrue($result);
// Test that mode has been changed
$this->assertEquals(Functions::COMPATIBILITY_GNUMERIC, Functions::getCompatibilityMode());
}
public function testInvalidCompatibilityMode()
{
$result = Functions::setCompatibilityMode('INVALIDMODE');
// Test for a false response for failure
$this->assertFalse($result);
// Test that mode has not been changed
$this->assertEquals(Functions::COMPATIBILITY_EXCEL, Functions::getCompatibilityMode());
}
public function testReturnDateType()
{
$result = Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
// Test for a true response for success
$this->assertTrue($result);
// Test that mode has been changed
$this->assertEquals(Functions::RETURNDATE_PHP_OBJECT, Functions::getReturnDateType());
}
public function testInvalidReturnDateType()
{
$result = Functions::setReturnDateType('INVALIDTYPE');
// Test for a false response for failure
$this->assertFalse($result);
// Test that mode has not been changed
$this->assertEquals(Functions::RETURNDATE_EXCEL, Functions::getReturnDateType());
2015-05-17 13:00:02 +00:00
}
public function testDUMMY()
{
$result = Functions::DUMMY();
self::assertEquals('#Not Yet Implemented', $result);
2015-05-17 13:00:02 +00:00
}
public function testDIV0()
{
$result = Functions::DIV0();
self::assertEquals('#DIV/0!', $result);
2015-05-17 13:00:02 +00:00
}
public function testNA()
{
$result = Functions::NA();
self::assertEquals('#N/A', $result);
2015-05-17 13:00:02 +00:00
}
2016-05-14 08:29:38 +00:00
public function testNAN()
2015-05-17 13:00:02 +00:00
{
$result = Functions::NAN();
self::assertEquals('#NUM!', $result);
2015-05-17 13:00:02 +00:00
}
public function testNAME()
{
$result = Functions::NAME();
self::assertEquals('#NAME?', $result);
2015-05-17 13:00:02 +00:00
}
public function testREF()
{
$result = Functions::REF();
self::assertEquals('#REF!', $result);
2015-05-17 13:00:02 +00:00
}
public function testNULL()
{
$result = Functions::null();
self::assertEquals('#NULL!', $result);
2015-05-17 13:00:02 +00:00
}
public function testVALUE()
{
$result = Functions::VALUE();
self::assertEquals('#VALUE!', $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsBlank
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsBlank($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isBlank(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsBlank()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_BLANK.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsErr
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsErr($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isErr(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsErr()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_ERR.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsError
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsError($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isError(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsError()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_ERROR.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerErrorType
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testErrorType($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::errorType(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerErrorType()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/ERROR_TYPE.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsLogical
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsLogical($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isLogical(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsLogical()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_LOGICAL.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsNa
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsNa($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isNa(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsNa()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_NA.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsNumber
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsNumber($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isNumber(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsNumber()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_NUMBER.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsText
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsText($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isText(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsText()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_TEXT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsNonText
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsNonText($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isNonText(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsNonText()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_NONTEXT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsEven
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsEven($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isEven(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsEven()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_EVEN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
2016-05-18 07:02:39 +00:00
* @dataProvider providerIsOdd
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testIsOdd($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::isOdd(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
2016-05-18 07:02:39 +00:00
public function providerIsOdd()
2012-07-31 20:56:11 +00:00
{
return require 'data/Calculation/Functions/IS_ODD.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerTYPE
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testTYPE($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::TYPE(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerTYPE()
{
return require 'data/Calculation/Functions/TYPE.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = Functions::n(...$args);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerN()
{
return require 'data/Calculation/Functions/N.php';
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerIsFormula
*
* @param mixed $expectedResult
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
* @param mixed $reference Reference to the cell we wish to test
* @param mixed $value Value of the cell we wish to test
*/
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
public function testIsFormula($expectedResult, $reference, $value = 'undefined')
{
$ourCell = null;
if ($value !== 'undefined') {
$remoteCell = $this->getMockBuilder(Cell::class)
->disableOriginalConstructor()
->getMock();
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
$remoteCell->method('isFormula')
->will($this->returnValue(substr($value, 0, 1) == '='));
$remoteSheet = $this->getMockBuilder(Worksheet::class)
->disableOriginalConstructor()
->getMock();
$remoteSheet->method('getCell')
->will($this->returnValue($remoteCell));
$workbook = $this->getMockBuilder(Spreadsheet::class)
->disableOriginalConstructor()
->getMock();
$workbook->method('getSheetByName')
->will($this->returnValue($remoteSheet));
$sheet = $this->getMockBuilder(Worksheet::class)
->disableOriginalConstructor()
->getMock();
$sheet->method('getCell')
->will($this->returnValue($remoteCell));
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
$sheet->method('getParent')
->will($this->returnValue($workbook));
$ourCell = $this->getMockBuilder(Cell::class)
->disableOriginalConstructor()
->getMock();
$ourCell->method('getWorksheet')
->will($this->returnValue($sheet));
}
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
$result = Functions::isFormula($reference, $ourCell);
2020-04-27 10:28:36 +00:00
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
}
public function providerIsFormula()
{
return require 'data/Calculation/Functions/ISFORMULA.php';
}
/**
* @dataProvider providerIfCondition
*
* @param mixed $expectedResult
*/
public function testIfCondition($expectedResult, ...$args)
{
$result = Functions::ifCondition(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerIfCondition()
{
return require 'data/Calculation/Functions/IF_CONDITION.php';
}
2012-07-31 20:56:11 +00:00
}