|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; |
| 4 | + |
| 5 | +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; |
| 6 | +use PHPUnit\Framework\TestCase; |
| 7 | + |
| 8 | +class Issue2516Test extends TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @var string |
| 12 | + */ |
| 13 | + private static $testbook = 'tests/data/Reader/XLSX/issue.2516b.xlsx'; |
| 14 | + |
| 15 | + public function testPreliminaries(): void |
| 16 | + { |
| 17 | + $file = 'zip://'; |
| 18 | + $file .= self::$testbook; |
| 19 | + $file .= '#docProps/thumbnail.wmf'; |
| 20 | + $data = file_get_contents($file); |
| 21 | + |
| 22 | + // confirm that file exists |
| 23 | + self::assertNotFalse($data, 'thumbnail.wmf not exists'); |
| 24 | + |
| 25 | + $file = 'zip://'; |
| 26 | + $file .= self::$testbook; |
| 27 | + $file .= '#_rels/.rels'; |
| 28 | + $data = file_get_contents($file); |
| 29 | + // confirm that file contains expected namespaced xml tag |
| 30 | + if ($data === false) { |
| 31 | + self::fail('Unable to read file .rels'); |
| 32 | + } else { |
| 33 | + self::assertStringContainsString('Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.wmf"', $data); |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + public function testIssue2516a(): void |
| 38 | + { |
| 39 | + $filename = self::$testbook; |
| 40 | + $reader = new Xlsx(); |
| 41 | + $names = $reader->listWorksheetNames($filename); |
| 42 | + $expected = ['Sheet1']; |
| 43 | + self::assertSame($expected, $names); |
| 44 | + } |
| 45 | + |
| 46 | + public function testIssue2516b(): void |
| 47 | + { |
| 48 | + $filename = self::$testbook; |
| 49 | + $reader = new Xlsx(); |
| 50 | + $infos = $reader->listWorksheetInfo($filename); |
| 51 | + $expected = [ |
| 52 | + [ |
| 53 | + 'worksheetName' => 'Sheet1', |
| 54 | + 'lastColumnLetter' => 'B', |
| 55 | + 'lastColumnIndex' => 1, |
| 56 | + 'totalRows' => '6', |
| 57 | + 'totalColumns' => 2, |
| 58 | + ], |
| 59 | + ]; |
| 60 | + self::assertSame($expected, $infos); |
| 61 | + } |
| 62 | +} |
0 commit comments