| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Cell\Cell; | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Spreadsheet; | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | 
					
						
							| 
									
										
										
										
											2017-11-08 15:48:01 +00:00
										 |  |  | use PHPUnit\Framework\TestCase; | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 15:48:01 +00:00
										 |  |  | 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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | 
					
						
							|  |  |  |         Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testCompatibilityMode(): void | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $result = Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); | 
					
						
							|  |  |  |         // Test for a true response for success
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertTrue($result); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |         // Test that mode has been changed
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertEquals(Functions::COMPATIBILITY_GNUMERIC, Functions::getCompatibilityMode()); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testInvalidCompatibilityMode(): void | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $result = Functions::setCompatibilityMode('INVALIDMODE'); | 
					
						
							|  |  |  |         // Test for a false response for failure
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertFalse($result); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |         // Test that mode has not been changed
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertEquals(Functions::COMPATIBILITY_EXCEL, Functions::getCompatibilityMode()); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testReturnDateType(): void | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $result = Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); | 
					
						
							|  |  |  |         // Test for a true response for success
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertTrue($result); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |         // Test that mode has been changed
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertEquals(Functions::RETURNDATE_PHP_OBJECT, Functions::getReturnDateType()); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testInvalidReturnDateType(): void | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $result = Functions::setReturnDateType('INVALIDTYPE'); | 
					
						
							|  |  |  |         // Test for a false response for failure
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertFalse($result); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |         // Test that mode has not been changed
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::assertEquals(Functions::RETURNDATE_EXCEL, Functions::getReturnDateType()); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testDUMMY(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::DUMMY(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#Not Yet Implemented', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testDIV0(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::DIV0(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#DIV/0!', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testNA(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::NA(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#N/A', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testNAN(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::NAN(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#NUM!', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testNAME(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::NAME(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#NAME?', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testREF(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::REF(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#REF!', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testNULL(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::null(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals('#NULL!', $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testVALUE(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = Functions::VALUE(); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsBlank($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsErr($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsError($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testErrorType($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsLogical($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsNa($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsNumber($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsText($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsNonText($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsEven($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/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 | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsOdd($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/Calculation/Functions/IS_ODD.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerTYPE | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testTYPE($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/Calculation/Functions/TYPE.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerN | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testN($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +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() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/Calculation/Functions/N.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerIsFormula | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIsFormula($expectedResult, $reference, $value = 'undefined'): void | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $ourCell = null; | 
					
						
							|  |  |  |         if ($value !== 'undefined') { | 
					
						
							|  |  |  |             $remoteCell = $this->getMockBuilder(Cell::class) | 
					
						
							|  |  |  |                 ->disableOriginalConstructor() | 
					
						
							|  |  |  |                 ->getMock(); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |             $remoteCell->method('isFormula') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn(substr($value, 0, 1) == '='); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $remoteSheet = $this->getMockBuilder(Worksheet::class) | 
					
						
							|  |  |  |                 ->disableOriginalConstructor() | 
					
						
							|  |  |  |                 ->getMock(); | 
					
						
							|  |  |  |             $remoteSheet->method('getCell') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn($remoteCell); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $workbook = $this->getMockBuilder(Spreadsheet::class) | 
					
						
							|  |  |  |                 ->disableOriginalConstructor() | 
					
						
							|  |  |  |                 ->getMock(); | 
					
						
							|  |  |  |             $workbook->method('getSheetByName') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn($remoteSheet); | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $sheet = $this->getMockBuilder(Worksheet::class) | 
					
						
							|  |  |  |                 ->disableOriginalConstructor() | 
					
						
							|  |  |  |                 ->getMock(); | 
					
						
							|  |  |  |             $sheet->method('getCell') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn($remoteCell); | 
					
						
							| 
									
										
										
										
											2018-07-22 18:17:04 +00:00
										 |  |  |             $sheet->method('getParent') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn($workbook); | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $ourCell = $this->getMockBuilder(Cell::class) | 
					
						
							|  |  |  |                 ->disableOriginalConstructor() | 
					
						
							|  |  |  |                 ->getMock(); | 
					
						
							|  |  |  |             $ourCell->method('getWorksheet') | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |                 ->willReturn($sheet); | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function providerIsFormula() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/Calculation/Functions/ISFORMULA.php'; | 
					
						
							| 
									
										
										
										
											2018-02-24 12:14:48 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-06-02 02:34:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerIfCondition | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testIfCondition($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2018-06-02 02:34:44 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $result = Functions::ifCondition(...$args); | 
					
						
							|  |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function providerIfCondition() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/Calculation/Functions/IF_CONDITION.php'; | 
					
						
							| 
									
										
										
										
											2018-06-02 02:34:44 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 20:56:11 +00:00
										 |  |  | } |