mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
use PhpOffice\PhpSpreadsheet\Shared\File;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class EmptyFileTest extends TestCase
|
|
{
|
|
/** @var string */
|
|
private $tempfile = '';
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
if ($this->tempfile !== '') {
|
|
unlink($this->tempfile);
|
|
$this->tempfile = '';
|
|
}
|
|
}
|
|
|
|
public function testEmptyFileLoad(): void
|
|
{
|
|
$this->expectException(ReaderException::class);
|
|
$this->expectExceptionMessage('Could not find zip member');
|
|
$this->tempfile = $temp = File::temporaryFileName();
|
|
file_put_contents($temp, '');
|
|
$reader = new Xlsx();
|
|
$reader->load($temp);
|
|
}
|
|
|
|
public function testEmptyFileNames(): void
|
|
{
|
|
$this->expectException(ReaderException::class);
|
|
$this->expectExceptionMessage('Could not find zip member');
|
|
$this->tempfile = $temp = File::temporaryFileName();
|
|
file_put_contents($temp, '');
|
|
$reader = new Xlsx();
|
|
$reader->listWorksheetNames($temp);
|
|
}
|
|
|
|
public function testEmptyInfo(): void
|
|
{
|
|
$this->expectException(ReaderException::class);
|
|
$this->expectExceptionMessage('Could not find zip member');
|
|
$this->tempfile = $temp = File::temporaryFileName();
|
|
file_put_contents($temp, '');
|
|
$reader = new Xlsx();
|
|
$reader->listWorksheetInfo($temp);
|
|
}
|
|
}
|