Additional Unit Tests (#1582)
This commit is contained in:
		
							parent
							
								
									8712fb0424
								
							
						
					
					
						commit
						b89968d206
					
				| @ -95,4 +95,21 @@ class ReferenceHelperTest extends TestCase | ||||
|             self::assertEquals($columnExpectedResult[$key], $value); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @dataProvider providerFormulaUpdates | ||||
|      */ | ||||
|     public function testUpdateFormula(string $formula, int $insertRows, int $insertColumns, string $worksheet, string $expectedResult): void | ||||
|     { | ||||
|         $referenceHelper = ReferenceHelper::getInstance(); | ||||
| 
 | ||||
|         $result = $referenceHelper->updateFormulaReferences($formula, 'A1', $insertRows, $insertColumns, $worksheet); | ||||
| 
 | ||||
|         self::assertSame($expectedResult, $result); | ||||
|     } | ||||
| 
 | ||||
|     public function providerFormulaUpdates(): array | ||||
|     { | ||||
|         return require 'tests/data/ReferenceHelperFormulaUpdates.php'; | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										74
									
								
								tests/data/ReferenceHelperFormulaUpdates.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								tests/data/ReferenceHelperFormulaUpdates.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,74 @@ | ||||
| <?php | ||||
| 
 | ||||
| return [ | ||||
|     [ | ||||
|         '=SUM(C3:E5)', | ||||
|         -2, | ||||
|         -2, | ||||
|         '2020', | ||||
|         '=SUM(A1:C3)', | ||||
|     ], | ||||
|     [ | ||||
|         '=SUM(2020!C3:E5,2019!C3:E5)', | ||||
|         -2, | ||||
|         -2, | ||||
|         '2020', | ||||
|         '=SUM(2020!A1:C3,2019!C3:E5)', | ||||
|     ], | ||||
|     [ | ||||
|         '=SUM(2020!3:5,2019!3:5)', | ||||
|         -2, | ||||
|         -2, | ||||
|         '2020', | ||||
|         '=SUM(2020!1:3,2019!3:5)', | ||||
|     ], | ||||
|     [ | ||||
|         '=SUM(2020!C:E,2019!C:E)', | ||||
|         -2, | ||||
|         -2, | ||||
|         '2020', | ||||
|         '=SUM(2020!A:C,2019!C:E)', | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2019', | ||||
|         "=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B3)-1))", | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!B$1=\"\",\"-\",(('2020'!B$1/'2019'!B$1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2019', | ||||
|         "=IF('2020'!B\$1=\"\",\"-\",(('2020'!B\$1/'2019'!D\$1)-1))", | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!Z$1=\"\",\"-\",(('2020'!Z$1/'2019'!Z$1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2019', | ||||
|         "=IF('2020'!Z\$1=\"\",\"-\",(('2020'!Z\$1/'2019'!AB\$1)-1))", | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2020', | ||||
|         "=IF('2020'!\$B3=\"\",\"-\",(('2020'!\$B3/'2019'!\$B1)-1))", | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!B$1=\"\",\"-\",(('2020'!B$1/'2019'!B$1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2020', | ||||
|         "=IF('2020'!D\$1=\"\",\"-\",(('2020'!D\$1/'2019'!B\$1)-1))", | ||||
|     ], | ||||
|     [ | ||||
|         "=IF('2020'!Z$1=\"\",\"-\",(('2020'!Z$1/'2019'!Z$1)-1))", | ||||
|         2, | ||||
|         2, | ||||
|         '2020', | ||||
|         "=IF('2020'!AB\$1=\"\",\"-\",(('2020'!AB\$1/'2019'!Z\$1)-1))", | ||||
|     ], | ||||
| ]; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Mark Baker
						Mark Baker