| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-29 08:39:42 +00:00
										 |  |  | namespace PhpOffice\PhpSpreadsheetTests\Cell; | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Cell\Coordinate; | 
					
						
							| 
									
										
										
										
											2016-08-31 17:18:12 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Exception; | 
					
						
							| 
									
										
										
										
											2017-11-08 15:48:01 +00:00
										 |  |  | use PHPUnit\Framework\TestCase; | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  | use TypeError; | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  | class CoordinateTest extends TestCase | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerColumnString | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2017-11-25 10:26:41 +00:00
										 |  |  |      * @param mixed $string | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testColumnIndexFromString($expectedResult, $string): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-11-25 10:26:41 +00:00
										 |  |  |         $columnIndex = Coordinate::columnIndexFromString($string); | 
					
						
							|  |  |  |         self::assertEquals($expectedResult, $columnIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $stringBack = Coordinate::stringFromColumnIndex($columnIndex); | 
					
						
							|  |  |  |         self::assertEquals($stringBack, $string, 'should be able to get the original input with opposite method'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerColumnString() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/ColumnString.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testColumnIndexFromStringTooLong(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = 'ABCD'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::columnIndexFromString($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testColumnIndexFromStringTooShort(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = ''; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::columnIndexFromString($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Column string index can not be empty'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerColumnIndex | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2017-11-25 10:26:41 +00:00
										 |  |  |      * @param int $columnIndex | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testStringFromColumnIndex($expectedResult, $columnIndex): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-11-25 10:26:41 +00:00
										 |  |  |         $string = Coordinate::stringFromColumnIndex($columnIndex); | 
					
						
							|  |  |  |         self::assertEquals($expectedResult, $string); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $columnIndexBack = Coordinate::columnIndexFromString($string); | 
					
						
							|  |  |  |         self::assertEquals($columnIndexBack, $columnIndex, 'should be able to get the original input with opposite method'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerColumnIndex() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/ColumnIndex.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerCoordinates | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testCoordinateFromString($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::coordinateFromString($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerCoordinates() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellCoordinates.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testCoordinateFromStringWithRangeAddress(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = 'A1:AI2012'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::coordinateFromString($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testCoordinateFromStringWithEmptyAddress(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = ''; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::coordinateFromString($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testCoordinateFromStringWithInvalidAddress(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = 'AI'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::coordinateFromString($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Invalid cell coordinate ' . $cellAddress); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerAbsoluteCoordinates | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $expectedResult | 
					
						
							|  |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testAbsoluteCoordinateFromString($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::absoluteCoordinate($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerAbsoluteCoordinates() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellAbsoluteCoordinate.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testAbsoluteCoordinateFromStringWithRangeAddress(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = 'A1:AI2012'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::absoluteCoordinate($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerAbsoluteReferences | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testAbsoluteReferenceFromString($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::absoluteReference($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerAbsoluteReferences() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellAbsoluteReference.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testAbsoluteReferenceFromStringWithRangeAddress(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $cellAddress = 'A1:AI2012'; | 
					
						
							| 
									
										
										
										
											2017-10-01 11:07:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |             Coordinate::absoluteReference($cellAddress); | 
					
						
							| 
									
										
										
										
											2015-05-29 20:35:35 +00:00
										 |  |  |         } catch (\Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |             self::assertInstanceOf(Exception::class, $e); | 
					
						
							|  |  |  |             self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         self::fail('An expected exception has not been raised.'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerSplitRange | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testSplitRange($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::splitRange($rangeSet); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         foreach ($result as $key => $split) { | 
					
						
							|  |  |  |             if (!is_array($expectedResult[$key])) { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |                 self::assertEquals($expectedResult[$key], $split[0]); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |                 self::assertEquals($expectedResult[$key], $split); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerSplitRange() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellSplitRange.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerBuildRange | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testBuildRange($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |         $result = Coordinate::buildRange(...$args); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerBuildRange() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellBuildRange.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testBuildRangeInvalid(): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |         $this->expectException(TypeError::class); | 
					
						
							| 
									
										
										
										
											2018-01-28 06:59:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:15:04 +00:00
										 |  |  |         $cellRange = ''; | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |         Coordinate::buildRange($cellRange); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerRangeBoundaries | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testRangeBoundaries($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::rangeBoundaries($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerRangeBoundaries() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellRangeBoundaries.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerRangeDimension | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testRangeDimension($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::rangeDimension($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerRangeDimension() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellRangeDimension.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerGetRangeBoundaries | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testGetRangeBoundaries($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::getRangeBoundaries($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerGetRangeBoundaries() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellGetRangeBoundaries.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerExtractAllCellReferencesInRange | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param array $expectedResult | 
					
						
							|  |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testExtractAllCellReferencesInRange($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::extractAllCellReferencesInRange($rangeSet); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-31 12:00:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerExtractAllCellReferencesInRange() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellExtractAllCellReferencesInRange.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-07-31 18:36:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-30 21:54:38 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerInvalidRange | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $range | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testExtractAllCellReferencesInRangeInvalidRange($range): void | 
					
						
							| 
									
										
										
										
											2018-05-30 21:54:38 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->expectException(Exception::class); | 
					
						
							|  |  |  |         $this->expectExceptionMessage('Invalid range: "' . $range . '"'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Coordinate::extractAllCellReferencesInRange($range); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function providerInvalidRange() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return [['Z1:A1'], ['A4:A1'], ['B1:A1'], ['AA1:Z1']]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-31 18:36:54 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerMergeRangesInCollection | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-05-18 04:49:57 +00:00
										 |  |  |     public function testMergeRangesInCollection($expectedResult, ...$args): void | 
					
						
							| 
									
										
										
										
											2017-07-31 18:36:54 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-11-18 14:12:55 +00:00
										 |  |  |         $result = Coordinate::mergeRangesInCollection(...$args); | 
					
						
							| 
									
										
										
										
											2017-09-20 05:55:42 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							| 
									
										
										
										
											2017-07-31 18:36:54 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function providerMergeRangesInCollection() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CellMergeRangesInCollection.php'; | 
					
						
							| 
									
										
										
										
											2017-07-31 18:36:54 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-01-09 21:31:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerCoordinateIsRange | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |      * @param string $rangeSet | 
					
						
							| 
									
										
										
										
											2018-01-09 21:31:06 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |     public function testCoordinateIsRange($expectedResult, $rangeSet): void | 
					
						
							| 
									
										
										
										
											2018-01-09 21:31:06 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-02 05:38:35 +00:00
										 |  |  |         $result = Coordinate::coordinateIsRange($rangeSet); | 
					
						
							| 
									
										
										
										
											2018-01-09 21:31:06 +00:00
										 |  |  |         self::assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function providerCoordinateIsRange() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-05-17 09:35:55 +00:00
										 |  |  |         return require 'tests/data/CoordinateIsRange.php'; | 
					
						
							| 
									
										
										
										
											2018-01-09 21:31:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-07-29 19:56:35 +00:00
										 |  |  | } |