RowTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
  3. use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
  4. class RowTest extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerROW
  8. *
  9. * @param mixed $expectedResult
  10. * @param null|array|string $cellReference
  11. */
  12. public function testROW($expectedResult, $cellReference = null): void
  13. {
  14. $result = LookupRef\RowColumnInformation::ROW($cellReference);
  15. self::assertSame($expectedResult, $result);
  16. }
  17. public function providerROW(): array
  18. {
  19. return require 'tests/data/Calculation/LookupRef/ROW.php';
  20. }
  21. public function testROWwithNull(): void
  22. {
  23. $sheet = $this->getSheet();
  24. $sheet->getCell('C4')->setValue('=ROW()');
  25. self::assertSame(4, $sheet->getCell('C4')->getCalculatedValue());
  26. $sheet->getCell('D2')->setValue('=ROW(C13)');
  27. self::assertSame(13, $sheet->getCell('D2')->getCalculatedValue());
  28. // Sheetnames don't have to exist
  29. $sheet->getCell('D3')->setValue('=ROW(Sheet17!E15)');
  30. self::assertSame(15, $sheet->getCell('D3')->getCalculatedValue());
  31. $sheet->getCell('D4')->setValue("=ROW('Worksheet #5'!X500)");
  32. self::assertSame(500, $sheet->getCell('D4')->getCalculatedValue());
  33. }
  34. }