mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-08-05 15:07:26 +02:00
php8 support
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
<?php
|
||||
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the nelexa/zip package.
|
||||
* (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PhpZip\Tests\Extra\Fields;
|
||||
|
||||
@@ -8,32 +15,22 @@ use PHPUnit\Framework\TestCase;
|
||||
use PhpZip\Exception\ZipException;
|
||||
use PhpZip\Model\Extra\Fields\AbstractUnicodeExtraField;
|
||||
|
||||
/**
|
||||
* Class AbstractUnicodeExtraFieldTest.
|
||||
*/
|
||||
abstract class AbstractUnicodeExtraFieldTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return string|AbstractUnicodeExtraField
|
||||
*
|
||||
* @psalm-var class-string<\PhpZip\Model\Extra\Fields\AbstractUnicodeExtraField>
|
||||
* @psalm-var class-string<AbstractUnicodeExtraField>
|
||||
*/
|
||||
abstract protected function getUnicodeExtraFieldClassName();
|
||||
|
||||
/**
|
||||
* @dataProvider provideExtraField
|
||||
*
|
||||
* @param int $crc32
|
||||
* @param string $unicodePath
|
||||
* @param string $originalPath
|
||||
* @param string $binaryData
|
||||
*
|
||||
* @throws ZipException
|
||||
*/
|
||||
public function testExtraField($crc32, $unicodePath, $originalPath, $binaryData)
|
||||
public function testExtraField(int $crc32, string $unicodePath, string $originalPath, string $binaryData): void
|
||||
{
|
||||
$crc32 = (int) $crc32; // for php 32-bit
|
||||
|
||||
$className = $this->getUnicodeExtraFieldClassName();
|
||||
|
||||
/** @var AbstractUnicodeExtraField $extraField */
|
||||
@@ -48,12 +45,9 @@ abstract class AbstractUnicodeExtraFieldTest extends TestCase
|
||||
static::assertEquals($className::unpackCentralDirData($binaryData), $extraField);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract public function provideExtraField();
|
||||
abstract public function provideExtraField(): array;
|
||||
|
||||
public function testSetter()
|
||||
public function testSetter(): void
|
||||
{
|
||||
$className = $this->getUnicodeExtraFieldClassName();
|
||||
$entryName = '11111';
|
||||
@@ -74,12 +68,10 @@ abstract class AbstractUnicodeExtraFieldTest extends TestCase
|
||||
/**
|
||||
* @throws ZipException
|
||||
*/
|
||||
public function testUnicodeErrorParse()
|
||||
public function testUnicodeErrorParse(): void
|
||||
{
|
||||
$this->expectException(
|
||||
ZipException::class,
|
||||
'Unicode path extra data must have at least 5 bytes.'
|
||||
);
|
||||
$this->expectException(ZipException::class);
|
||||
$this->expectExceptionMessage('Unicode path extra data must have at least 5 bytes.');
|
||||
|
||||
$className = $this->getUnicodeExtraFieldClassName();
|
||||
$className::unpackLocalFileData('');
|
||||
@@ -88,12 +80,10 @@ abstract class AbstractUnicodeExtraFieldTest extends TestCase
|
||||
/**
|
||||
* @throws ZipException
|
||||
*/
|
||||
public function testUnknownVersionParse()
|
||||
public function testUnknownVersionParse(): void
|
||||
{
|
||||
$this->expectException(
|
||||
ZipException::class,
|
||||
'Unsupported version [2] for Unicode path extra data.'
|
||||
);
|
||||
$this->expectException(ZipException::class);
|
||||
$this->expectExceptionMessage('Unsupported version [2] for Unicode path extra data.');
|
||||
|
||||
$className = $this->getUnicodeExtraFieldClassName();
|
||||
$className::unpackLocalFileData("\x02\x04a\xD28\xC3\xA4\\\xC3\xBC.txt");
|
||||
|
Reference in New Issue
Block a user