Skip to content

Commit a6fc466

Browse files
Merge pull request #17 from DeepDiver1975/chore/cleanup-tests
chore: cleanup tests folder
2 parents f565926 + 8c0ee5b commit a6fc466

17 files changed

+125
-143
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
strategy:
5353
fail-fast: false
5454
matrix:
55-
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
55+
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
5656
coverage: [ 'xdebug' ] # ZipStreamerTest depends on xdebug_get_headers => if coverage none/pcov then xdebug is disabled.
5757
steps:
5858
- name: Checkout
@@ -83,7 +83,7 @@ jobs:
8383
run: composer install --no-progress --prefer-dist --optimize-autoloader
8484

8585
- name: PHPUnit
86-
run: vendor/bin/phpunit --verbose --configuration test/phpunit.xml
86+
run: vendor/bin/phpunit --verbose --configuration tests/phpunit.xml
8787
# run: vendor/bin/phpunit --verbose --configuration tests/phpunit.xml --coverage-clover=coverage.xml
8888

8989

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/composer.lock
22
/composer.phar
3-
/test/.phpunit.result.cache
3+
/tests/.phpunit.result.cache
4+
/vendor

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,13 @@
3535
"role": "Contributor"
3636
}
3737
],
38-
"repositories": [
39-
{
40-
"type": "vcs",
41-
"url": "https://github.com/DeepDiver1975/PHPZipStreamer"
42-
}
43-
],
4438
"require": {
45-
"php": ">=7.1"
39+
"php": ">=7.1",
40+
"ext-mbstring": "*"
4641
},
4742
"require-dev": {
43+
"ext-xdebug": "*",
44+
"ext-zlib": "*",
4845
"phpunit/phpunit": "^7 || ^8"
4946
},
5047
"suggest": {
@@ -54,5 +51,10 @@
5451
"psr-4": {
5552
"ZipStreamer\\": "src/"
5653
}
54+
},
55+
"autoload-dev": {
56+
"psr-4": {
57+
"Tests\\": "tests/"
58+
}
5759
}
5860
}

src/Count64.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
*/
2323
namespace ZipStreamer;
2424

25-
use \ZipStreamer\Lib\Count64_32;
26-
use \ZipStreamer\Lib\Count64_64;
25+
use ZipStreamer\Lib\Count64_32;
26+
use ZipStreamer\Lib\Count64_64;
27+
use ZipStreamer\Lib\Count64Base;
2728

2829
const INT64_HIGH_MAP = 0xffffffff00000000;
2930
const INT64_LOW_MAP = 0x00000000ffffffff;
@@ -43,16 +44,6 @@ function urShift($bits, $shift) {
4344
return ($bits >> $shift) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($shift - 1));
4445
}
4546

46-
/**
47-
* Convert binary data string to readable hex string
48-
*
49-
* @param string $data binary string
50-
* @return string readable hex string
51-
*/
52-
function byte2hex($data) {
53-
return unpack("h*", $data);
54-
}
55-
5647
/**
5748
* Pack 1 byte data into binary string
5849
*
@@ -149,8 +140,8 @@ abstract class Count64 {
149140
public static function construct($value = 0, $limit32Bit = False) {
150141
if (4 == PHP_INT_SIZE) {
151142
return new Count64_32($value, $limit32Bit);
152-
} else {
153-
return new Count64_64($value, $limit32Bit);
154143
}
144+
145+
return new Count64_64($value, $limit32Bit);
155146
}
156147
}

src/Lib/Count64Base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
abstract class Count64Base {
2626
protected $limit32Bit = False;
2727

28-
function __construct($value = 0, $limit32Bit = False) {
28+
public function __construct($value = 0, $limit32Bit = False) {
2929
$this->limit32Bit = $limit32Bit;
3030
$this->set($value);
3131
}

src/Lib/Count64_32.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function set($value) {
4242
if (is_int($value)) {
4343
$this->loBytes = $value;
4444
$this->hiBytes = 0;
45-
} else if (is_array($value) && 2 == sizeof($value)) {
45+
} else if (is_array($value) && 2 == count($value)) {
4646
$this->loBytes = $value[0];
4747
if ($this->limit32Bit && 0 !== $value[1]) {
4848
throw new \OverflowException(self::EXCEPTION_32BIT_OVERFLOW);

src/Lib/Count64_64.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
*/
2323
namespace ZipStreamer\Lib;
2424

25-
use const \ZipStreamer\INT64_LOW_MAP;
26-
use const \ZipStreamer\INT_MAX_32;
25+
use function ZipStreamer\urShift;
26+
use const ZipStreamer\INT64_LOW_MAP;
27+
use const ZipStreamer\INT_MAX_32;
2728

2829
class Count64_64 extends Count64Base {
2930
private $value;
@@ -46,7 +47,7 @@ public function set($value) {
4647
throw new \OverFlowException(self::EXCEPTION_32BIT_OVERFLOW);
4748
}
4849
$this->value = $value;
49-
} else if (is_array($value) && 2 == sizeof($value)) {
50+
} else if (is_array($value) && 2 == count($value)) {
5051
if ($this->limit32Bit && 0 !== $value[1]) {
5152
throw new \OverFlowException(self::EXCEPTION_32BIT_OVERFLOW);
5253
}

src/ZipStreamer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ZipStreamer {
4848
private $extFileAttrFile;
4949
private $extFileAttrDir;
5050

51-
/** @var stream output stream zip file is written to */
51+
/** @var resource $outStream output stream zip file is written to */
5252
private $outStream;
5353
/** @var boolean zip64 enabled */
5454
private $zip64 = True;
@@ -438,7 +438,7 @@ private function addDataDescriptor($dataLength, $gzLength, $dataCRC32) {
438438

439439
private function buildZip64EndOfCentralDirectoryRecord($cdRecLength) {
440440
$versionToExtract = $this->getVersionToExtract(False);
441-
$cdRecCount = sizeof($this->cdRec);
441+
$cdRecCount = count($this->cdRec);
442442

443443
return ''
444444
. pack32le(self::ZIP64_END_OF_CENTRAL_DIRECTORY) // zip64 end of central dir signature 4 bytes (0x06064b50)
@@ -517,12 +517,12 @@ private function buildCentralDirectoryHeader($filePath, $timestamp, $gpFlags,
517517
private function buildEndOfCentralDirectoryRecord($cdRecLength) {
518518
if ($this->zip64) {
519519
$diskNumber = -1;
520-
$cdRecCount = min(sizeof($this->cdRec), 0xffff);
520+
$cdRecCount = min(count($this->cdRec), 0xffff);
521521
$cdRecLength = -1;
522522
$offset = -1;
523523
} else {
524524
$diskNumber = 0;
525-
$cdRecCount = sizeof($this->cdRec);
525+
$cdRecCount = count($this->cdRec);
526526
$offset = $this->offset->getLoBytes();
527527
}
528528
//throw new \Exception(sprintf("zip64 %d diskno %d", $this->zip64, $diskNumber));
@@ -646,7 +646,7 @@ protected function __construct($level) {
646646
$class = self::PECL2_DEFLATE_STREAM_CLASS;
647647
}
648648
if (!class_exists($class)) {
649-
new \Exception('unable to instantiate PECL deflate stream (requires pecl_http >= 0.10)');
649+
throw new \Exception('unable to instantiate PECL deflate stream (requires pecl_http >= 0.10)');
650650
}
651651

652652
$deflateFlags = constant($class . '::TYPE_RAW');
@@ -723,8 +723,8 @@ class GPFLAGS {
723723

724724
// compression settings for deflate/deflate64
725725
const DEFL_NORM = 0x0000; // normal compression (COMP1 and COMP2 not set)
726-
const DEFL_MAX = COMP1; // maximum compression
727-
const DEFL_FAST = COMP2; // fast compression
726+
const DEFL_MAX = self::COMP1; // maximum compression
727+
const DEFL_FAST = self::COMP2; // fast compression
728728
const DEFL_SFAST = 0x0006; // superfast compression (COMP1 and COMP2 set)
729729
}
730730

test/integration/Dockerfile

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)