diff options
author | Mario Vavti <mario@mariovavti.com> | 2024-11-09 11:27:53 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2024-11-09 11:27:53 +0100 |
commit | 954d92c354aef93cac7079472c55b53ac4a07d2a (patch) | |
tree | 9ece7278658a82e7f21e71a8cdc7cc13f5d91aed /vendor/maennchen/zipstream-php/test/Zip64 | |
parent | 8dbebc2b426ac3a27d2476acb6ccc2f353f4212a (diff) | |
parent | 14207c68ca451c365b3fe1f8d267409da39f9498 (diff) | |
download | volse-hubzilla-954d92c354aef93cac7079472c55b53ac4a07d2a.tar.gz volse-hubzilla-954d92c354aef93cac7079472c55b53ac4a07d2a.tar.bz2 volse-hubzilla-954d92c354aef93cac7079472c55b53ac4a07d2a.zip |
Merge branch 'dev' into containers
Diffstat (limited to 'vendor/maennchen/zipstream-php/test/Zip64')
4 files changed, 139 insertions, 0 deletions
diff --git a/vendor/maennchen/zipstream-php/test/Zip64/DataDescriptorTest.php b/vendor/maennchen/zipstream-php/test/Zip64/DataDescriptorTest.php new file mode 100644 index 000000000..49fb2ccb2 --- /dev/null +++ b/vendor/maennchen/zipstream-php/test/Zip64/DataDescriptorTest.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace ZipStream\Test\Zip64; + +use PHPUnit\Framework\TestCase; +use ZipStream\Zip64\DataDescriptor; + +class DataDescriptorTest extends TestCase +{ + public function testSerializesCorrectly(): void + { + $descriptor = DataDescriptor::generate( + crc32UncompressedData: 0x11111111, + compressedSize: (0x77777777 << 32) + 0x66666666, + uncompressedSize: (0x99999999 << 32) + 0x88888888, + ); + + $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 + ); + } +} diff --git a/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryLocatorTest.php b/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryLocatorTest.php new file mode 100644 index 000000000..271a29862 --- /dev/null +++ b/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryLocatorTest.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace ZipStream\Test\Zip64; + +use PHPUnit\Framework\TestCase; +use ZipStream\Zip64\EndOfCentralDirectoryLocator; + +class EndOfCentralDirectoryLocatorTest extends TestCase +{ + public function testSerializesCorrectly(): void + { + $descriptor = EndOfCentralDirectoryLocator::generate( + numberOfTheDiskWithZip64CentralDirectoryStart: 0x11111111, + zip64centralDirectoryStartOffsetOnDisk: (0x22222222 << 32) + 0x33333333, + totalNumberOfDisks: 0x44444444, + ); + + $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 + ); + } +} diff --git a/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryTest.php b/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryTest.php new file mode 100644 index 000000000..b86fb1781 --- /dev/null +++ b/vendor/maennchen/zipstream-php/test/Zip64/EndOfCentralDirectoryTest.php @@ -0,0 +1,41 @@ +<?php + +declare(strict_types=1); + +namespace ZipStream\Test\Zip64; + +use PHPUnit\Framework\TestCase; +use ZipStream\Zip64\EndOfCentralDirectory; + +class EndOfCentralDirectoryTest extends TestCase +{ + public function testSerializesCorrectly(): void + { + $descriptor = EndOfCentralDirectory::generate( + versionMadeBy: 0x3333, + versionNeededToExtract: 0x4444, + numberOfThisDisk: 0x55555555, + numberOfTheDiskWithCentralDirectoryStart: 0x66666666, + numberOfCentralDirectoryEntriesOnThisDisk: (0x77777777 << 32) + 0x88888888, + numberOfCentralDirectoryEntries: (0x99999999 << 32) + 0xAAAAAAAA, + sizeOfCentralDirectory: (0xBBBBBBBB << 32) + 0xCCCCCCCC, + centralDirectoryStartOffsetOnDisk: (0xDDDDDDDD << 32) + 0xEEEEEEEE, + extensibleDataSector: 'foo', + ); + + $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') + ); + } +} diff --git a/vendor/maennchen/zipstream-php/test/Zip64/ExtendedInformationExtraFieldTest.php b/vendor/maennchen/zipstream-php/test/Zip64/ExtendedInformationExtraFieldTest.php new file mode 100644 index 000000000..904783d86 --- /dev/null +++ b/vendor/maennchen/zipstream-php/test/Zip64/ExtendedInformationExtraFieldTest.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); + +namespace ZipStream\Test\Zip64; + +use PHPUnit\Framework\TestCase; +use ZipStream\Zip64\ExtendedInformationExtraField; + +class ExtendedInformationExtraFieldTest extends TestCase +{ + public function testSerializesCorrectly(): void + { + $extraField = ExtendedInformationExtraField::generate( + originalSize: (0x77777777 << 32) + 0x66666666, + compressedSize: (0x99999999 << 32) + 0x88888888, + relativeHeaderOffset: (0x22222222 << 32) + 0x11111111, + diskStartNumber: 0x33333333, + ); + + $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 + ); + } + + public function testSerializesEmptyCorrectly(): void + { + $extraField = ExtendedInformationExtraField::generate(); + + $this->assertSame( + bin2hex($extraField), + '0100' . // 2 bytes; Tag for this "extra" block type + '0000' // 2 bytes; Size of this "extra" block + ); + } +} |