generated from jric11/baseProject
Codex's updates...
This commit is contained in:
+15
-6
@@ -24,7 +24,9 @@ final class CallbackOutputTest extends TestCase
|
||||
$buf = '';
|
||||
$zip = new ZipStream(
|
||||
outputStream: CallbackStreamWrapper::open(
|
||||
static function (string $chunk) use (&$buf): void { $buf .= $chunk; }
|
||||
static function (string $chunk) use (&$buf): void {
|
||||
$buf .= $chunk;
|
||||
}
|
||||
),
|
||||
sendHttpHeaders: false
|
||||
);
|
||||
@@ -53,10 +55,14 @@ final class CallbackOutputTest extends TestCase
|
||||
$buf2 = '';
|
||||
|
||||
$stream1 = CallbackStreamWrapper::open(
|
||||
static function (string $chunk) use (&$buf1): void { $buf1 .= $chunk; }
|
||||
static function (string $chunk) use (&$buf1): void {
|
||||
$buf1 .= $chunk;
|
||||
}
|
||||
);
|
||||
$stream2 = CallbackStreamWrapper::open(
|
||||
static function (string $chunk) use (&$buf2): void { $buf2 .= $chunk; }
|
||||
static function (string $chunk) use (&$buf2): void {
|
||||
$buf2 .= $chunk;
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertIsResource($stream1);
|
||||
@@ -112,7 +118,8 @@ final class CallbackOutputTest extends TestCase
|
||||
public function testStreamPositionTracking(): void
|
||||
{
|
||||
$stream = CallbackStreamWrapper::open(
|
||||
static function (string $chunk): void { /* no-op */ }
|
||||
static function (string $chunk): void { // no-op
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertSame(0, ftell($stream));
|
||||
@@ -129,7 +136,8 @@ final class CallbackOutputTest extends TestCase
|
||||
public function testInvalidModeRejection(): void
|
||||
{
|
||||
$stream = CallbackStreamWrapper::open(
|
||||
static function (string $chunk): void { /* no-op */ }
|
||||
static function (string $chunk): void { // no-op
|
||||
}
|
||||
);
|
||||
|
||||
// Close the stream first
|
||||
@@ -143,7 +151,8 @@ final class CallbackOutputTest extends TestCase
|
||||
public function testStreamStatistics(): void
|
||||
{
|
||||
$stream = CallbackStreamWrapper::open(
|
||||
static function (string $chunk): void { /* no-op */ }
|
||||
static function (string $chunk): void { // no-op
|
||||
}
|
||||
);
|
||||
|
||||
fwrite($stream, 'test data');
|
||||
|
||||
@@ -35,26 +35,26 @@ class CentralDirectoryFileHeaderTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($header),
|
||||
'504b0102' . // 4 bytes; central file header signature
|
||||
'0306' . // 2 bytes; version made by
|
||||
'2d00' . // 2 bytes; version needed to extract
|
||||
'2222' . // 2 bytes; general purpose bit flag
|
||||
'0800' . // 2 bytes; compression method
|
||||
'2008' . // 2 bytes; last mod file time
|
||||
'2154' . // 2 bytes; last mod file date
|
||||
'11111111' . // 4 bytes; crc-32
|
||||
'77777777' . // 4 bytes; compressed size
|
||||
'99999999' . // 4 bytes; uncompressed size
|
||||
'0800' . // 2 bytes; file name length (n)
|
||||
'0c00' . // 2 bytes; extra field length (m)
|
||||
'0c00' . // 2 bytes; file comment length (o)
|
||||
'0000' . // 2 bytes; disk number start
|
||||
'0000' . // 2 bytes; internal file attributes
|
||||
'20000000' . // 4 bytes; external file attributes
|
||||
'34120000' . // 4 bytes; relative offset of local header
|
||||
'746573742e706e67' . // n bytes; file name
|
||||
'736f6d6520636f6e74656e74' . // m bytes; extra field
|
||||
'736f6d6520636f6d6d656e74' // o bytes; file comment
|
||||
'504b0102' // 4 bytes; central file header signature
|
||||
. '0306' // 2 bytes; version made by
|
||||
. '2d00' // 2 bytes; version needed to extract
|
||||
. '2222' // 2 bytes; general purpose bit flag
|
||||
. '0800' // 2 bytes; compression method
|
||||
. '2008' // 2 bytes; last mod file time
|
||||
. '2154' // 2 bytes; last mod file date
|
||||
. '11111111' // 4 bytes; crc-32
|
||||
. '77777777' // 4 bytes; compressed size
|
||||
. '99999999' // 4 bytes; uncompressed size
|
||||
. '0800' // 2 bytes; file name length (n)
|
||||
. '0c00' // 2 bytes; extra field length (m)
|
||||
. '0c00' // 2 bytes; file comment length (o)
|
||||
. '0000' // 2 bytes; disk number start
|
||||
. '0000' // 2 bytes; internal file attributes
|
||||
. '20000000' // 4 bytes; external file attributes
|
||||
. '34120000' // 4 bytes; relative offset of local header
|
||||
. '746573742e706e67' // n bytes; file name
|
||||
. '736f6d6520636f6e74656e74' // m bytes; extra field
|
||||
. '736f6d6520636f6d6d656e74' // o bytes; file comment
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ class DataDescriptorTest extends TestCase
|
||||
compressedSize: 0x77777777,
|
||||
uncompressedSize: 0x99999999,
|
||||
)),
|
||||
'504b0708' . // 4 bytes; Optional data descriptor signature = 0x08074b50
|
||||
'11111111' . // 4 bytes; CRC-32 of uncompressed data
|
||||
'77777777' . // 4 bytes; Compressed size
|
||||
'99999999' // 4 bytes; Uncompressed size
|
||||
'504b0708' // 4 bytes; Optional data descriptor signature = 0x08074b50
|
||||
. '11111111' // 4 bytes; CRC-32 of uncompressed data
|
||||
. '77777777' // 4 bytes; Compressed size
|
||||
. '99999999' // 4 bytes; Uncompressed size
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ class EndOfCentralDirectoryTest extends TestCase
|
||||
centralDirectoryStartOffsetOnDisk: 0x33,
|
||||
zipFileComment: 'foo',
|
||||
)),
|
||||
'504b0506' . // 4 bytes; end of central dir signature 0x06054b50
|
||||
'0000' . // 2 bytes; number of this disk
|
||||
'0000' . // 2 bytes; number of the disk with the start of the central directory
|
||||
'1000' . // 2 bytes; total number of entries in the central directory on this disk
|
||||
'1000' . // 2 bytes; total number of entries in the central directory
|
||||
'22000000' . // 4 bytes; size of the central directory
|
||||
'33000000' . // 4 bytes; offset of start of central directory with respect to the starting disk number
|
||||
'0300' . // 2 bytes; .ZIP file comment length
|
||||
bin2hex('foo')
|
||||
'504b0506' // 4 bytes; end of central dir signature 0x06054b50
|
||||
. '0000' // 2 bytes; number of this disk
|
||||
. '0000' // 2 bytes; number of the disk with the start of the central directory
|
||||
. '1000' // 2 bytes; total number of entries in the central directory on this disk
|
||||
. '1000' // 2 bytes; total number of entries in the central directory
|
||||
. '22000000' // 4 bytes; size of the central directory
|
||||
. '33000000' // 4 bytes; offset of start of central directory with respect to the starting disk number
|
||||
. '0300' // 2 bytes; .ZIP file comment length
|
||||
. bin2hex('foo')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class EndlessCycleStream implements StreamInterface
|
||||
throw new RuntimeException('Infinite Stream!');
|
||||
}
|
||||
|
||||
public function getMetadata(?string $key = null): array|null
|
||||
public function getMetadata(?string $key = null): ?array
|
||||
{
|
||||
return $key !== null ? null : [];
|
||||
}
|
||||
|
||||
+13
-13
@@ -29,19 +29,19 @@ class LocalFileHeaderTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex((string) $header),
|
||||
'504b0304' . // 4 bytes; Local file header signature
|
||||
'2d00' . // 2 bytes; Version needed to extract (minimum)
|
||||
'2222' . // 2 bytes; General purpose bit flag
|
||||
'0800' . // 2 bytes; Compression method; e.g. none = 0, DEFLATE = 8
|
||||
'2008' . // 2 bytes; File last modification time
|
||||
'2154' . // 2 bytes; File last modification date
|
||||
'11111111' . // 4 bytes; CRC-32 of uncompressed data
|
||||
'77777777' . // 4 bytes; Compressed size (or 0xffffffff for ZIP64)
|
||||
'99999999' . // 4 bytes; Uncompressed size (or 0xffffffff for ZIP64)
|
||||
'0800' . // 2 bytes; File name length (n)
|
||||
'0c00' . // 2 bytes; Extra field length (m)
|
||||
'746573742e706e67' . // n bytes; File name
|
||||
'736f6d6520636f6e74656e74' // m bytes; Extra field
|
||||
'504b0304' // 4 bytes; Local file header signature
|
||||
. '2d00' // 2 bytes; Version needed to extract (minimum)
|
||||
. '2222' // 2 bytes; General purpose bit flag
|
||||
. '0800' // 2 bytes; Compression method; e.g. none = 0, DEFLATE = 8
|
||||
. '2008' // 2 bytes; File last modification time
|
||||
. '2154' // 2 bytes; File last modification date
|
||||
. '11111111' // 4 bytes; CRC-32 of uncompressed data
|
||||
. '77777777' // 4 bytes; Compressed size (or 0xffffffff for ZIP64)
|
||||
. '99999999' // 4 bytes; Uncompressed size (or 0xffffffff for ZIP64)
|
||||
. '0800' // 2 bytes; File name length (n)
|
||||
. '0c00' // 2 bytes; Extra field length (m)
|
||||
. '746573742e706e67' // n bytes; File name
|
||||
. '736f6d6520636f6e74656e74' // m bytes; Extra field
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace ZipStream\Test;
|
||||
|
||||
trait Tempfile
|
||||
{
|
||||
protected string|null $tempfile;
|
||||
protected ?string $tempfile;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
|
||||
@@ -19,10 +19,10 @@ class DataDescriptorTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($descriptor),
|
||||
'504b0708' . // 4 bytes; Optional data descriptor signature = 0x08074b50
|
||||
'11111111' . // 4 bytes; CRC-32 of uncompressed data
|
||||
'6666666677777777' . // 8 bytes; Compressed size
|
||||
'8888888899999999' // 8 bytes; Uncompressed size
|
||||
'504b0708' // 4 bytes; Optional data descriptor signature = 0x08074b50
|
||||
. '11111111' // 4 bytes; CRC-32 of uncompressed data
|
||||
. '6666666677777777' // 8 bytes; Compressed size
|
||||
. '8888888899999999' // 8 bytes; Uncompressed size
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -19,10 +19,10 @@ class EndOfCentralDirectoryLocatorTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($descriptor),
|
||||
'504b0607' . // 4 bytes; zip64 end of central dir locator signature - 0x07064b50
|
||||
'11111111' . // 4 bytes; number of the disk with the start of the zip64 end of central directory
|
||||
'3333333322222222' . // 28 bytes; relative offset of the zip64 end of central directory record
|
||||
'44444444' // 4 bytes;total number of disks
|
||||
'504b0607' // 4 bytes; zip64 end of central dir locator signature - 0x07064b50
|
||||
. '11111111' // 4 bytes; number of the disk with the start of the zip64 end of central directory
|
||||
. '3333333322222222' // 28 bytes; relative offset of the zip64 end of central directory record
|
||||
. '44444444' // 4 bytes;total number of disks
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,17 @@ class EndOfCentralDirectoryTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($descriptor),
|
||||
'504b0606' . // 4 bytes;zip64 end of central dir signature - 0x06064b50
|
||||
'2f00000000000000' . // 8 bytes; size of zip64 end of central directory record
|
||||
'3333' . // 2 bytes; version made by
|
||||
'4444' . // 2 bytes; version needed to extract
|
||||
'55555555' . // 4 bytes; number of this disk
|
||||
'66666666' . // 4 bytes; number of the disk with the start of the central directory
|
||||
'8888888877777777' . // 8 bytes; total number of entries in the central directory on this disk
|
||||
'aaaaaaaa99999999' . // 8 bytes; total number of entries in the central directory
|
||||
'ccccccccbbbbbbbb' . // 8 bytes; size of the central directory
|
||||
'eeeeeeeedddddddd' . // 8 bytes; offset of start of central directory with respect to the starting disk number
|
||||
bin2hex('foo')
|
||||
'504b0606' // 4 bytes;zip64 end of central dir signature - 0x06064b50
|
||||
. '2f00000000000000' // 8 bytes; size of zip64 end of central directory record
|
||||
. '3333' // 2 bytes; version made by
|
||||
. '4444' // 2 bytes; version needed to extract
|
||||
. '55555555' // 4 bytes; number of this disk
|
||||
. '66666666' // 4 bytes; number of the disk with the start of the central directory
|
||||
. '8888888877777777' // 8 bytes; total number of entries in the central directory on this disk
|
||||
. 'aaaaaaaa99999999' // 8 bytes; total number of entries in the central directory
|
||||
. 'ccccccccbbbbbbbb' // 8 bytes; size of the central directory
|
||||
. 'eeeeeeeedddddddd' // 8 bytes; offset of start of central directory with respect to the starting disk number
|
||||
. bin2hex('foo')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -20,12 +20,12 @@ class ExtendedInformationExtraFieldTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($extraField),
|
||||
'0100' . // 2 bytes; Tag for this "extra" block type
|
||||
'1c00' . // 2 bytes; Size of this "extra" block
|
||||
'6666666677777777' . // 8 bytes; Original uncompressed file size
|
||||
'8888888899999999' . // 8 bytes; Size of compressed data
|
||||
'1111111122222222' . // 8 bytes; Offset of local header record
|
||||
'33333333' // 4 bytes; Number of the disk on which this file starts
|
||||
'0100' // 2 bytes; Tag for this "extra" block type
|
||||
. '1c00' // 2 bytes; Size of this "extra" block
|
||||
. '6666666677777777' // 8 bytes; Original uncompressed file size
|
||||
. '8888888899999999' // 8 bytes; Size of compressed data
|
||||
. '1111111122222222' // 8 bytes; Offset of local header record
|
||||
. '33333333' // 4 bytes; Number of the disk on which this file starts
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ class ExtendedInformationExtraFieldTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex($extraField),
|
||||
'0100' . // 2 bytes; Tag for this "extra" block type
|
||||
'0000' // 2 bytes; Size of this "extra" block
|
||||
'0100' // 2 bytes; Tag for this "extra" block type
|
||||
. '0000' // 2 bytes; Size of this "extra" block
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-9
@@ -62,10 +62,10 @@ class ZipStreamTest extends TestCase
|
||||
|
||||
$name = 'árvíztűrő tükörfúrógép.txt';
|
||||
$content = 'Sample String Data';
|
||||
$comment =
|
||||
'Filename has every special characters ' .
|
||||
'from Hungarian language in lowercase. ' .
|
||||
'In uppercase: ÁÍŰŐÜÖÚÓÉ';
|
||||
$comment
|
||||
= 'Filename has every special characters '
|
||||
. 'from Hungarian language in lowercase. '
|
||||
. 'In uppercase: ÁÍŰŐÜÖÚÓÉ';
|
||||
|
||||
$zip->addFile(fileName: $name, data: $content, comment: $comment);
|
||||
$zip->finish();
|
||||
@@ -327,11 +327,14 @@ class ZipStreamTest extends TestCase
|
||||
defaultEnableZeroHeader: false,
|
||||
);
|
||||
|
||||
if (file_exists('/dev/null')) {
|
||||
$streamUnseekable = fopen('/dev/null', 'w+');
|
||||
} elseif (file_exists('NUL')) {
|
||||
$streamUnseekable = fopen('NUL', 'w+');
|
||||
} else {
|
||||
foreach (['cat', 'more'] as $cmd) {
|
||||
$streamUnseekable = @popen($cmd, 'w');
|
||||
if ($streamUnseekable !== false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($streamUnseekable === false) {
|
||||
$this->markTestSkipped('Needs file /dev/null');
|
||||
}
|
||||
|
||||
@@ -546,12 +549,24 @@ class ZipStreamTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
$zip->addDirectory('mydir/');
|
||||
|
||||
$zip->finish();
|
||||
|
||||
$tmpDir = $this->validateAndExtractZip($this->tempfile);
|
||||
|
||||
$files = $this->getRecursiveFileList($tmpDir);
|
||||
$this->assertSame(['sample0', 'sample1', 'sample2', 'sample3'], $files);
|
||||
|
||||
$this->assertFileDoesNotContain(
|
||||
$this->tempfile,
|
||||
PackField::pack(
|
||||
new PackField(format: 'V', value: 0x00000000), // CRC-32 = 0 (directory)
|
||||
new PackField(format: 'V', value: 0xFFFFFFFF), // compressedSize — bug sentinel
|
||||
new PackField(format: 'V', value: 0xFFFFFFFF), // uncompressedSize — bug sentinel
|
||||
new PackField(format: 'v', value: 6), // filename length = strlen('mydir/')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[Group('slow')]
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ class ExtendedInformationExtraFieldTest extends TestCase
|
||||
|
||||
$this->assertSame(
|
||||
bin2hex((string) $extraField),
|
||||
'5356' . // 2 bytes; Tag for this "extra" block type
|
||||
'0000' // 2 bytes; TODO: Document
|
||||
'5356' // 2 bytes; Tag for this "extra" block type
|
||||
. '0000' // 2 bytes; TODO: Document
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user