|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PhpOffice\PhpSpreadsheetTests; |
| 4 | + |
| 5 | +use PhpOffice\PhpSpreadsheet\IOFactory; |
| 6 | +use PhpOffice\PhpSpreadsheet\Shared\File; |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | + |
| 9 | +class Issue4521Test extends TestCase |
| 10 | +{ |
| 11 | + private string $outfile = ''; |
| 12 | + |
| 13 | + protected int $weirdMimetypeMajor = 8; |
| 14 | + |
| 15 | + protected int $weirdMimetypeMinor1 = 1; |
| 16 | + |
| 17 | + protected int $weirdMimetypeMinor2 = 2; |
| 18 | + |
| 19 | + protected function tearDown(): void |
| 20 | + { |
| 21 | + if ($this->outfile !== '') { |
| 22 | + unlink($this->outfile); |
| 23 | + $this->outfile = ''; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + public function testEmptyFile(): void |
| 28 | + { |
| 29 | + $this->outfile = File::temporaryFilename(); |
| 30 | + file_put_contents($this->outfile, ''); |
| 31 | + $spreadsheet = IOFactory::load($this->outfile); |
| 32 | + $sheet = $spreadsheet->getActiveSheet(); |
| 33 | + self::assertSame('A', $sheet->getHighestColumn()); |
| 34 | + self::assertSame(1, $sheet->getHighestRow()); |
| 35 | + $spreadsheet->disconnectWorksheets(); |
| 36 | + } |
| 37 | + |
| 38 | + public function testCrlfFile(): void |
| 39 | + { |
| 40 | + if (PHP_MAJOR_VERSION === $this->weirdMimetypeMajor) { |
| 41 | + if ( |
| 42 | + PHP_MINOR_VERSION === $this->weirdMimetypeMinor1 |
| 43 | + || PHP_MINOR_VERSION === $this->weirdMimetypeMinor2 |
| 44 | + ) { |
| 45 | + self::markTestSkipped('Php mimetype bug with this release'); |
| 46 | + } |
| 47 | + } |
| 48 | + $this->outfile = File::temporaryFilename(); |
| 49 | + file_put_contents($this->outfile, "\r\n"); |
| 50 | + $spreadsheet = IOFactory::load($this->outfile); |
| 51 | + $sheet = $spreadsheet->getActiveSheet(); |
| 52 | + self::assertSame('A', $sheet->getHighestColumn()); |
| 53 | + self::assertSame(1, $sheet->getHighestRow()); |
| 54 | + $spreadsheet->disconnectWorksheets(); |
| 55 | + } |
| 56 | +} |
0 commit comments