diff --git a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php index 374b63c9..08462b5b 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -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'; + } } diff --git a/tests/data/ReferenceHelperFormulaUpdates.php b/tests/data/ReferenceHelperFormulaUpdates.php new file mode 100644 index 00000000..b97b8a35 --- /dev/null +++ b/tests/data/ReferenceHelperFormulaUpdates.php @@ -0,0 +1,74 @@ +