|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; |
| 6 | + |
| 7 | +use PhpOffice\PhpSpreadsheet\Spreadsheet; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | + |
| 10 | +class InfoTest extends TestCase |
| 11 | +{ |
| 12 | + #[\PHPUnit\Framework\Attributes\DataProvider('providerINFO')] |
| 13 | + public function testINFO(mixed $expectedResult, string $typeText): void |
| 14 | + { |
| 15 | + $spreadsheet = new Spreadsheet(); |
| 16 | + $sheet = $spreadsheet->getActiveSheet(); |
| 17 | + |
| 18 | + $sheet->getCell('A1')->setValue('=INFO("' . $typeText . '")'); |
| 19 | + $result = $sheet->getCell('A1')->getCalculatedValue(); |
| 20 | + |
| 21 | + self::assertSame($expectedResult, $result); |
| 22 | + $spreadsheet->disconnectWorksheets(); |
| 23 | + } |
| 24 | + |
| 25 | + public static function providerINFO(): array |
| 26 | + { |
| 27 | + return require 'tests/data/Calculation/Information/INFO.php'; |
| 28 | + } |
| 29 | + |
| 30 | + public function testINFONumfileWithThreeSheets(): void |
| 31 | + { |
| 32 | + $spreadsheet = new Spreadsheet(); |
| 33 | + $spreadsheet->createSheet(); |
| 34 | + $spreadsheet->createSheet(); |
| 35 | + $sheet = $spreadsheet->getActiveSheet(); |
| 36 | + |
| 37 | + $sheet->getCell('A1')->setValue('=INFO("numfile")'); |
| 38 | + $result = $sheet->getCell('A1')->getCalculatedValue(); |
| 39 | + |
| 40 | + self::assertSame(3, $result); |
| 41 | + $spreadsheet->disconnectWorksheets(); |
| 42 | + } |
| 43 | +} |
0 commit comments