diff --git a/src/PhpSpreadsheet/Cell/AddressHelper.php b/src/PhpSpreadsheet/Cell/AddressHelper.php new file mode 100644 index 00000000..77a521b0 --- /dev/null +++ b/src/PhpSpreadsheet/Cell/AddressHelper.php @@ -0,0 +1,88 @@ +expectException(Exception::class); + + AddressHelper::convertToA1($address); + } + + public function providerR1C1ConversionToA1Exception() + { + return require 'tests/data/Cell/R1C1ConversionToA1Exception.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Absolute + */ + public function testA1ConversionToR1C1Absolute(string $expectedValue, string $address): void + { + $actualValue = AddressHelper::convertToR1C1($address); + + self::assertSame($expectedValue, $actualValue); + } + + public function providerA1ConversionToR1C1Absolute() + { + return require 'tests/data/Cell/A1ConversionToR1C1Absolute.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Relative + */ + public function testA1ConversionToR1C1Relative(string $expectedValue, string $address, ?int $row = null, ?int $column = null): void + { + $actualValue = AddressHelper::convertToR1C1($address, $row, $column); + + self::assertSame($expectedValue, $actualValue); + } + + public function providerA1ConversionToR1C1Relative() + { + return require 'tests/data/Cell/A1ConversionToR1C1Relative.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Exception + */ + public function testA1ConversionToR1C1Exception(string $address): void + { + $this->expectException(Exception::class); + + AddressHelper::convertToR1C1($address); + } + + public function providerA1ConversionToR1C1Exception() + { + return require 'tests/data/Cell/A1ConversionToR1C1Exception.php'; + } +} diff --git a/tests/data/Cell/A1ConversionToR1C1Absolute.php b/tests/data/Cell/A1ConversionToR1C1Absolute.php new file mode 100644 index 00000000..171672bb --- /dev/null +++ b/tests/data/Cell/A1ConversionToR1C1Absolute.php @@ -0,0 +1,15 @@ +