AddressTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
  5. use PHPUnit\Framework\TestCase;
  6. class AddressTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerADDRESS
  10. *
  11. * @param mixed $expectedResult
  12. */
  13. public function testADDRESS($expectedResult, ...$args): void
  14. {
  15. $result = LookupRef::cellAddress(...$args);
  16. self::assertEquals($expectedResult, $result);
  17. }
  18. public function providerADDRESS(): array
  19. {
  20. return require 'tests/data/Calculation/LookupRef/ADDRESS.php';
  21. }
  22. /**
  23. * @dataProvider providerAddressArray
  24. */
  25. public function testAddressArray(array $expectedResult, string $argument1, string $argument2): void
  26. {
  27. $calculation = Calculation::getInstance();
  28. $formula = "=ADDRESS({$argument1}, {$argument2}, 4)";
  29. $result = $calculation->_calculateFormulaValue($formula);
  30. self::assertEquals($expectedResult, $result);
  31. }
  32. public function providerAddressArray(): array
  33. {
  34. return [
  35. 'row/column vectors' => [
  36. [['A1', 'B1', 'C1'], ['A2', 'B2', 'C2'], ['A3', 'B3', 'C3']],
  37. '{1; 2; 3}',
  38. '{1, 2, 3}',
  39. ],
  40. ];
  41. }
  42. }