From b89968d20627805b7340a927588c2b9a7353f31b Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 14 Jul 2020 10:58:50 +0200 Subject: [PATCH] Additional Unit Tests (#1582) --- .../ReferenceHelperTest.php | 17 +++++ tests/data/ReferenceHelperFormulaUpdates.php | 74 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/data/ReferenceHelperFormulaUpdates.php 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 @@ +