|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; |
| 6 | + |
| 7 | +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; |
| 8 | + |
| 9 | +class Issue3770Test extends \PHPUnit\Framework\TestCase |
| 10 | +{ |
| 11 | + private static string $testbook = 'tests/data/Reader/XLSX/issue.3770.xlsx'; |
| 12 | + |
| 13 | + public function testPreliminaries(): void |
| 14 | + { |
| 15 | + $file = 'zip://'; |
| 16 | + $file .= self::$testbook; |
| 17 | + $file .= '#xl/_rels/workbook.xml.rels'; |
| 18 | + $data = file_get_contents($file); |
| 19 | + // rels file points to non-existent theme file |
| 20 | + if ($data === false) { |
| 21 | + self::fail('Unable to read file'); |
| 22 | + } else { |
| 23 | + self::assertStringContainsString('Target="theme/theme1.xml"', $data); |
| 24 | + self::assertStringContainsString('Target="worksheets/sheet1.xml"', $data); |
| 25 | + } |
| 26 | + $file = 'zip://'; |
| 27 | + $file .= self::$testbook; |
| 28 | + $file .= '#xl/theme/theme1.xml'; |
| 29 | + $data = @file_get_contents($file); |
| 30 | + self::assertFalse($data); |
| 31 | + $file = 'zip://'; |
| 32 | + $file .= self::$testbook; |
| 33 | + $file .= '#xl/worksheets/sheet1.xml'; |
| 34 | + $data = file_get_contents($file); |
| 35 | + self::assertNotFalse($data); |
| 36 | + } |
| 37 | + |
| 38 | + public function testLoadable(): void |
| 39 | + { |
| 40 | + $reader = new Xlsx(); |
| 41 | + $spreadsheet = $reader->load(self::$testbook); |
| 42 | + $sheet = $spreadsheet->getActiveSheet(); |
| 43 | + // Assert anything to confirm read succeeded |
| 44 | + self::assertSame('Универсальный передаточный документ', $sheet->getCell('A1')->getValue()); |
| 45 | + $spreadsheet->disconnectWorksheets(); |
| 46 | + } |
| 47 | +} |
0 commit comments