Skip to content

Commit 755642c

Browse files
author
Steph Fox
committed
- Bring phar tests into line across all branches
1 parent 2feac2e commit 755642c

File tree

289 files changed

+16493
-572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+16493
-572
lines changed

ext/phar/tests/008.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Phar::mapPhar truncated manifest (not enough for manifest length)
44
<?php if (!extension_loaded("phar")) die("skip");?>
55
--FILE--
66
<?php
7-
$file = (binary)"<?php
7+
$file = "<?php
88
Phar::mapPhar('hio');
99
__HALT_COMPILER(); ?>";
10-
$file .= pack('V', 500) . (binary)'notenough';
10+
$file .= pack('V', 500) . 'notenough';
1111
file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
1212
try {
1313
include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';

ext/phar/tests/009.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Phar::mapPhar too many manifest entries
66
phar.require_hash=0
77
--FILE--
88
<?php
9-
$file = (binary)"<?php
9+
$file = b"<?php
1010
Phar::mapPhar('hio');
1111
__HALT_COMPILER(); ?>";
12-
$file .= pack('VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . (binary)str_repeat('A', 500);
12+
$file .= pack('VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . str_repeat('A', 500);
1313
file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
1414
try {
1515
include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';

ext/phar/tests/010.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Phar::mapPhar buffer overrun
66
phar.require_hash=0
77
--FILE--
88
<?php
9-
$file = (binary)"<?php
9+
$file = b"<?php
1010
Phar::mapPhar('hio');
1111
__HALT_COMPILER(); ?>";
1212

1313
// this fails because the manifest length does not include the other 10 byte manifest data
1414

15-
$manifest = pack('V', 1) . (binary)'a' . pack('VVVVVV', 0, time(), 0, crc32((binary)''), 0x00000000, 0);
16-
$file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . (binary)'hio' . pack('V', 0) . (binary)$manifest;
15+
$manifest = pack('V', 1) . 'a' . pack('VVVVVV', 0, time(), 0, crc32(b''), 0x00000000, 0);
16+
$file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . 'hio' . pack('V', 0) . $manifest;
1717

1818
file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
1919
try {

ext/phar/tests/011.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ phar.require_hash=0
88
<?php
99
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1010
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php
11+
$file = "<?php
1212
Phar::mapPhar('hio');
1313
__HALT_COMPILER(); ?>";
1414

15-
// compressed file length does not match incompressed length for an uncompressed file
15+
// compressed file length does not match incompressed lentgh for an uncompressed file
1616

1717
$files = array();
1818
$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2);;

ext/phar/tests/012.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phar.require_hash=0
99

1010
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1111
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php
12+
$file = "<?php
1313
Phar::mapPhar('hio');
1414
__HALT_COMPILER(); ?>";
1515

ext/phar/tests/013.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ phar.require_hash=0
88
<?php
99
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1010
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
11+
$file = "<?php __HALT_COMPILER(); ?>";
1212
// filesize should be 1, and is 2
1313

1414
$files = array();

ext/phar/tests/014.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ phar.require_hash=0
88
<?php
99
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1010
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
11+
$file = "<?php __HALT_COMPILER(); ?>";
1212
// wrong crc32
1313

1414
$files = array();
15-
$files['a'] = array('cont'=>'a', 'crc32'=>crc32((binary)'aX'));
15+
$files['a'] = array('cont'=>'a', 'crc32'=>crc32(b'aX'));
1616
include 'files/phar_test.inc';
1717

1818
echo file_get_contents($pname.'/a');

ext/phar/tests/015.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phar.require_hash=0
99
<?php
1010
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1111
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
12+
$file = "<?php __HALT_COMPILER(); ?>";
1313

1414
$files = array();
1515
$files['a'] = array('cont'=>'a','comp'=>chr(75) . chr(4) . chr(0) /* 'a' gzdeflated */, 'flags'=>0x00001000);

ext/phar/tests/015b.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phar.require_hash=0
99
<?php
1010
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1111
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
12+
$file = "<?php __HALT_COMPILER(); ?>";
1313

1414
$files = array();
1515
$files['a'] = array('cont'=>'Hello World', 'comp'=>pack('H*', '425a6834314159265359065c89da0000009780400000400080060490002000310c082031a916c41d41e2ee48a70a1200cb913b40'),'flags'=>0x00002000);

ext/phar/tests/016.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phar.require_hash=0
99
<?php
1010
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1111
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
12+
$file = "<?php __HALT_COMPILER(); ?>";
1313
// file length is too short
1414

1515
$files = array();

ext/phar/tests/016b.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phar.require_hash=0
99
<?php
1010
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1111
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php __HALT_COMPILER(); ?>";
12+
$file = "<?php __HALT_COMPILER(); ?>";
1313
// file length is too short
1414

1515
$files = array();

ext/phar/tests/017.phpt

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
--TEST--
22
Phar: opendir test - no dir specified at all
33
--SKIPIF--
4-
<?php if (!extension_loaded("phar")) die("skip"); ?>
4+
<?php
5+
if (!extension_loaded("phar")) die("skip");
6+
if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7+
?>
58
--INI--
69
phar.require_hash=0
710
--FILE--
811
<?php
912
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1013
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php
14+
$file = "<?php
1215
Phar::mapPhar('hio');
16+
var_dump(__FILE__);
17+
var_dump(substr(__FILE__, 0, 4) != 'phar');
1318
__HALT_COMPILER(); ?>";
1419

1520
$files = array();
1621
$files['a'] = 'abc';
1722
include 'files/phar_test.inc';
1823

19-
include $fname;
24+
include $pname;
2025
$dir = opendir('phar://hio');
2126
?>
2227
--CLEAN--
2328
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
2429
--EXPECTF--
30+
string(%d) "%s017.phar.php"
31+
bool(true)
32+
2533
Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory (always use full path to a new phar)
2634
phar url "phar://hio" is unknown in %s017.php on line %d

ext/phar/tests/017U.phpt

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Phar: opendir test - no dir specified at all
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("phar")) die("skip");
6+
if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
7+
?>
8+
--INI--
9+
phar.require_hash=0
10+
--FILE--
11+
<?php
12+
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
13+
$pname = 'phar://' . $fname;
14+
$file = b"<?php
15+
Phar::mapPhar('hio');
16+
var_dump(__FILE__);
17+
var_dump(substr(__FILE__, 0, 4) != 'phar');
18+
__HALT_COMPILER(); ?>";
19+
20+
$files = array();
21+
$files['a'] = 'abc';
22+
include 'files/phar_test.inc';
23+
24+
include $pname;
25+
$dir = opendir('phar://hio');
26+
?>
27+
--CLEAN--
28+
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
29+
--EXPECTF--
30+
unicode(%d) "%s017U.phar.php"
31+
bool(true)
32+
33+
Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory (always use full path to a new phar)
34+
phar url "phar://hio" is unknown in %s017U.php on line %d

ext/phar/tests/018.phpt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
--TEST--
22
Phar: opendir test, root directory
33
--SKIPIF--
4-
<?php if (!extension_loaded("phar")) die("skip"); ?>
4+
<?php
5+
if (!extension_loaded("phar")) die("skip");
6+
if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7+
?>
58
--INI--
69
phar.require_hash=0
710
--FILE--
811
<?php
912
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1013
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php
14+
$file = "<?php
1215
Phar::mapPhar('hio');
1316
__HALT_COMPILER(); ?>";
1417

@@ -19,12 +22,10 @@ include 'files/phar_test.inc';
1922

2023
include $fname;
2124
$dir = opendir('phar://hio/');
22-
2325
while (false !== ($a = readdir($dir))) {
2426
var_dump($a);
2527
var_dump(is_dir('phar://hio/' . $a));
2628
}
27-
2829
?>
2930
--CLEAN--
3031
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>

ext/phar/tests/018U.phpt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Phar: opendir test, root directory
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("phar")) die("skip");
6+
if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
7+
?>
8+
--INI--
9+
phar.require_hash=0
10+
--FILE--
11+
<?php
12+
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
13+
$pname = 'phar://' . $fname;
14+
$file = b"<?php
15+
Phar::mapPhar('hio');
16+
__HALT_COMPILER(); ?>";
17+
18+
$files = array();
19+
$files['a'] = 'a';
20+
$files['b/a'] = 'b';
21+
include 'files/phar_test.inc';
22+
23+
include $fname;
24+
$dir = opendir('phar://hio/');
25+
while (false !== ($a = readdir($dir))) {
26+
var_dump($a);
27+
var_dump(is_dir('phar://hio/' . $a));
28+
}
29+
?>
30+
--CLEAN--
31+
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
32+
--EXPECT--
33+
unicode(1) "a"
34+
bool(false)
35+
unicode(1) "b"
36+
bool(true)

ext/phar/tests/019.phpt

+15-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Phar: opendir test, subdirectory
66
phar.require_hash=0
77
--FILE--
88
<?php
9+
910
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1011
$pname = 'phar://' . $fname;
11-
$file = (binary)"<?php
12+
$file = b"<?php
1213
Phar::mapPhar('hio');
1314
__HALT_COMPILER(); ?>";
1415

@@ -17,18 +18,24 @@ $files['a'] = 'a';
1718
$files['b/a'] = 'b';
1819
$files['b/c/d'] = 'c';
1920
$files['bad/c'] = 'd';
21+
2022
include 'files/phar_test.inc';
2123
include $fname;
24+
2225
$dir = opendir('phar://hio/b');
23-
while (false !== ($a = readdir($dir))) {
24-
var_dump($a);
25-
var_dump(is_dir('phar://hio/b/' . $a));
26+
27+
if ($dir) {
28+
while (false !== ($a = readdir($dir))) {
29+
var_dump($a);
30+
var_dump(is_dir('phar://hio/b/' . $a));
31+
}
2632
}
33+
2734
?>
2835
--CLEAN--
2936
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
30-
--EXPECT--
31-
string(1) "a"
37+
--EXPECTF--
38+
%s(1) "a"
3239
bool(false)
33-
string(1) "c"
34-
bool(true)
40+
%s(1) "c"
41+
bool(true)

ext/phar/tests/019b.phpt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
--TEST--
22
Phar: opendir test, recurse into
33
--SKIPIF--
4-
<?php if (!extension_loaded("phar")) die("skip"); ?>
5-
<?php if (!version_compare(phpversion(), 6, '<')) die("skip: permanent loop FIXME"); ?>
4+
<?php
5+
if (!extension_loaded("phar")) die("skip");
6+
if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7+
?>
68
--INI--
79
phar.require_hash=0
810
--FILE--
911
<?php
1012
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
1113
$pname = 'phar://' . $fname;
12-
$file = (binary)"<?php
14+
$file = "<?php
1315
Phar::mapPhar('hio');
1416
__HALT_COMPILER(); ?>";
1517

0 commit comments

Comments
 (0)