diff --git a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php index 374b63c960..08462b5b60 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -95,4 +95,21 @@ public function testCellReverseSort(): void 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'; + } } diff --git a/tests/data/ReferenceHelperFormulaUpdates.php b/tests/data/ReferenceHelperFormulaUpdates.php new file mode 100644 index 0000000000..b97b8a3592 --- /dev/null +++ b/tests/data/ReferenceHelperFormulaUpdates.php @@ -0,0 +1,74 @@ +