EmptyFileTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods;
  3. use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
  4. use PhpOffice\PhpSpreadsheet\Reader\Ods;
  5. use PhpOffice\PhpSpreadsheet\Shared\File;
  6. use PHPUnit\Framework\TestCase;
  7. class EmptyFileTest extends TestCase
  8. {
  9. /** @var string */
  10. private $tempfile = '';
  11. protected function tearDown(): void
  12. {
  13. if ($this->tempfile !== '') {
  14. unlink($this->tempfile);
  15. $this->tempfile = '';
  16. }
  17. }
  18. public function testEmptyFileLoad(): void
  19. {
  20. $this->expectException(ReaderException::class);
  21. $this->expectExceptionMessage('Could not find zip member');
  22. $this->tempfile = $temp = File::temporaryFileName();
  23. file_put_contents($temp, '');
  24. $reader = new Ods();
  25. $reader->load($temp);
  26. }
  27. public function testEmptyFileNames(): void
  28. {
  29. $this->expectException(ReaderException::class);
  30. $this->expectExceptionMessage('Could not find zip member');
  31. $this->tempfile = $temp = File::temporaryFileName();
  32. file_put_contents($temp, '');
  33. $reader = new Ods();
  34. $reader->listWorksheetNames($temp);
  35. }
  36. public function testEmptyInfo(): void
  37. {
  38. $this->expectException(ReaderException::class);
  39. $this->expectExceptionMessage('Could not find zip member');
  40. $this->tempfile = $temp = File::temporaryFileName();
  41. file_put_contents($temp, '');
  42. $reader = new Ods();
  43. $reader->listWorksheetInfo($temp);
  44. }
  45. }