mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
new tests for zlib extension, tested on windows, linux and linux64
This commit is contained in:
parent
9ea96c467a
commit
fc4a0d3886
87 changed files with 4686 additions and 0 deletions
39
ext/zlib/tests/gzclose_basic.phpt
Normal file
39
ext/zlib/tests/gzclose_basic.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzclose() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// note that gzclose is an alias to fclose. parameter checking tests will be
|
||||||
|
// the same as fclose
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
gzread($h, 20);
|
||||||
|
var_dump(gzclose($h));
|
||||||
|
|
||||||
|
//should fail.
|
||||||
|
gzread($h, 20);
|
||||||
|
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
gzread($h, 20);
|
||||||
|
var_dump(fclose($h));
|
||||||
|
|
||||||
|
//should fail.
|
||||||
|
gzread($h, 20);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
Warning: gzread(): %d is not a valid stream resource in %s on line %d
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
Warning: gzread(): %d is not a valid stream resource in %s on line %d
|
||||||
|
===DONE===
|
33
ext/zlib/tests/gzclose_error.phpt
Normal file
33
ext/zlib/tests/gzclose_error.phpt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzclose() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(gzclose( $h, $extra_arg ) );
|
||||||
|
var_dump(gzclose());
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzclose() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzclose() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
58
ext/zlib/tests/gzeof_basic.phpt
Normal file
58
ext/zlib/tests/gzeof_basic.phpt
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
--TEST--
|
||||||
|
Test function feof() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// note that gzeof is an alias to gzeof. parameter checking tests will be
|
||||||
|
// the same as gzeof
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
echo "-- test 1 --\n";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
gzpassthru($h);
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
echo "\n-- test 2 --\n";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo "reading 50 characters. eof should be false\n";
|
||||||
|
gzread($h, 50)."\n";
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
echo "reading 250 characters. eof should be true\n";
|
||||||
|
gzread($h, 250)."\n";
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
echo "reading 20 characters. eof should be true still\n";
|
||||||
|
gzread($h, 20)."\n";
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
-- test 1 --
|
||||||
|
bool(false)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
-- test 2 --
|
||||||
|
reading 50 characters. eof should be false
|
||||||
|
bool(false)
|
||||||
|
reading 250 characters. eof should be true
|
||||||
|
bool(true)
|
||||||
|
reading 20 characters. eof should be true still
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
28
ext/zlib/tests/gzeof_error.phpt
Normal file
28
ext/zlib/tests/gzeof_error.phpt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzeof() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzeof( $h, $extra_arg ) );
|
||||||
|
var_dump(gzeof() );
|
||||||
|
gzclose($h)
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzeof() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzeof() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
31
ext/zlib/tests/gzeof_variation1.phpt
Normal file
31
ext/zlib/tests/gzeof_variation1.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzeof while writing.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
$length = 10;
|
||||||
|
gzwrite( $h, $str );
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
gzwrite( $h, $str, $length);
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
gzclose($h);
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzeof(): %d is not a valid stream resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
39
ext/zlib/tests/gzfile_basic.phpt
Normal file
39
ext/zlib/tests/gzfile_basic.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() reading a gzip relative file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$plaintxt = b<<<EOT
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
EOT;
|
||||||
|
$dirname = 'gzfile_temp';
|
||||||
|
$filename = $dirname.'/plainfile.txt.gz';
|
||||||
|
mkdir($dirname);
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
gzwrite($h, $plaintxt);
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(gzfile( $filename ) );
|
||||||
|
|
||||||
|
unlink($filename);
|
||||||
|
rmdir($dirname);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(12) "hello world
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(22) "is a very common test
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(17) "for all languages"
|
||||||
|
}
|
||||||
|
===DONE===
|
39
ext/zlib/tests/gzfile_basic2.phpt
Normal file
39
ext/zlib/tests/gzfile_basic2.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() reading a plain relative file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$plaintxt = b<<<EOT
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
EOT;
|
||||||
|
$dirname = 'gzfile_temp';
|
||||||
|
$filename = $dirname.'/plainfile.txt';
|
||||||
|
mkdir($dirname);
|
||||||
|
$h = fopen($filename, 'w');
|
||||||
|
fwrite($h, $plaintxt);
|
||||||
|
fclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(gzfile( $filename ) );
|
||||||
|
|
||||||
|
unlink($filename);
|
||||||
|
rmdir($dirname);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(12) "hello world
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(22) "is a very common test
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(17) "for all languages"
|
||||||
|
}
|
||||||
|
===DONE===
|
29
ext/zlib/tests/gzfile_error.phpt
Normal file
29
ext/zlib/tests/gzfile_error.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$use_include_path = false;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
|
||||||
|
var_dump(gzfile( $filename, $use_include_path, $extra_arg ) );
|
||||||
|
|
||||||
|
var_dump(gzfile( ) );
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
43
ext/zlib/tests/gzfile_variation1.phpt
Normal file
43
ext/zlib/tests/gzfile_variation1.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with array values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$index_array = array(1, 2, 3);
|
||||||
|
$assoc_array = array(1 => 'one', 2 => 'two');
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
119
ext/zlib/tests/gzfile_variation10.phpt
Normal file
119
ext/zlib/tests/gzfile_variation10.phpt
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with emptyUnsetUndefNull values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$unset_var = 10;
|
||||||
|
unset($unset_var);
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
===DONE===
|
129
ext/zlib/tests/gzfile_variation11.phpt
Normal file
129
ext/zlib/tests/gzfile_variation11.phpt
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with float values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
===DONE===
|
108
ext/zlib/tests/gzfile_variation12.phpt
Normal file
108
ext/zlib/tests/gzfile_variation12.phpt
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with int values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array (
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
===DONE===
|
51
ext/zlib/tests/gzfile_variation13.phpt
Normal file
51
ext/zlib/tests/gzfile_variation13.phpt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with object values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
44
ext/zlib/tests/gzfile_variation14.phpt
Normal file
44
ext/zlib/tests/gzfile_variation14.phpt
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with string values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$variation_array = array(
|
||||||
|
'string DQ' => "string",
|
||||||
|
'string SQ' => 'string',
|
||||||
|
'mixed case string' => "sTrInG",
|
||||||
|
'heredoc' => $heredoc
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation_array as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
109
ext/zlib/tests/gzfile_variation15.phpt
Normal file
109
ext/zlib/tests/gzfile_variation15.phpt
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzfile() function : variation: use include path (relative directories in path)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once('reading_include_path.inc');
|
||||||
|
|
||||||
|
//define the files to go into these directories, create one in dir2
|
||||||
|
set_include_path($newIncludePath);
|
||||||
|
test_gzfile();
|
||||||
|
restore_include_path();
|
||||||
|
|
||||||
|
// remove the directory structure
|
||||||
|
chdir($baseDir);
|
||||||
|
rmdir($workingDir);
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
rmdir($newdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir("..");
|
||||||
|
rmdir($thisTestDir);
|
||||||
|
|
||||||
|
function test_gzfile() {
|
||||||
|
global $scriptFile, $secondFile, $firstFile, $filename;
|
||||||
|
|
||||||
|
// create a file in the middle directory
|
||||||
|
$h = gzopen($secondFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir2");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
// should read dir2 file
|
||||||
|
var_dump(gzfile($filename, true));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//create a file in dir1
|
||||||
|
$h = gzopen($firstFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir1");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should now read dir1 file
|
||||||
|
var_dump(gzfile($filename, true));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in working directory
|
||||||
|
$h = gzopen($filename, "w");
|
||||||
|
gzwrite($h, b"This is a file in working dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should still read dir1 file
|
||||||
|
var_dump(gzfile($filename, true));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
unlink($firstFile);
|
||||||
|
unlink($secondFile);
|
||||||
|
|
||||||
|
//should read the file in working directory
|
||||||
|
var_dump(gzfile($filename, true));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in the script directory
|
||||||
|
$h = gzopen($scriptFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in script dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should read the file in script dir
|
||||||
|
var_dump(gzfile($filename, true));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//cleanup
|
||||||
|
unlink($filename);
|
||||||
|
unlink($scriptFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(22) "This is a file in dir2"
|
||||||
|
}
|
||||||
|
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(22) "This is a file in dir1"
|
||||||
|
}
|
||||||
|
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(22) "This is a file in dir1"
|
||||||
|
}
|
||||||
|
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(29) "This is a file in working dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(28) "This is a file in script dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
===DONE===
|
||||||
|
|
40
ext/zlib/tests/gzfile_variation2.phpt
Normal file
40
ext/zlib/tests/gzfile_variation2.phpt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with boolean values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path =
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
50
ext/zlib/tests/gzfile_variation3.phpt
Normal file
50
ext/zlib/tests/gzfile_variation3.phpt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with emptyUnsetUndefNull values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$unset_var = 10;
|
||||||
|
unset($unset_var);
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
43
ext/zlib/tests/gzfile_variation4.phpt
Normal file
43
ext/zlib/tests/gzfile_variation4.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with float values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded(zlib)) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: gzfile(10.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(-10.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(-123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(0.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
39
ext/zlib/tests/gzfile_variation5.phpt
Normal file
39
ext/zlib/tests/gzfile_variation5.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with int values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array (
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: gzfile(0): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(1): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(12345): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(-2345): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
49
ext/zlib/tests/gzfile_variation6.phpt
Normal file
49
ext/zlib/tests/gzfile_variation6.phpt
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with object values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Error: 2 - gzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
Error: 2 - gzfile() expects parameter 1 to be string (Unicode or binary), object given, %s(%d)
|
||||||
|
NULL
|
44
ext/zlib/tests/gzfile_variation7.phpt
Normal file
44
ext/zlib/tests/gzfile_variation7.phpt
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 1 with string values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$variation_array = array(
|
||||||
|
'string DQ' => "string",
|
||||||
|
'string SQ' => 'string',
|
||||||
|
'mixed case string' => "sTrInG",
|
||||||
|
'heredoc' => $heredoc
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation_array as $var ) {
|
||||||
|
var_dump(gzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(sTrInG): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: gzfile(hello world): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
43
ext/zlib/tests/gzfile_variation8.phpt
Normal file
43
ext/zlib/tests/gzfile_variation8.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with array values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$index_array = array(1, 2, 3);
|
||||||
|
$assoc_array = array(1 => 'one', 2 => 'two');
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
107
ext/zlib/tests/gzfile_variation9.phpt
Normal file
107
ext/zlib/tests/gzfile_variation9.phpt
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzfile() by substituting agument 2 with boolean values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(gzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
array(6) {
|
||||||
|
[0]=>
|
||||||
|
string(36) "When you're taught through feelings
|
||||||
|
"
|
||||||
|
[1]=>
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
[2]=>
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
[3]=>
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
[4]=>
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
[5]=>
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
}
|
||||||
|
===DONE===
|
38
ext/zlib/tests/gzgetc_basic.phpt
Normal file
38
ext/zlib/tests/gzgetc_basic.phpt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzgetc() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// note that gzgets is an alias to fgets. parameter checking tests will be
|
||||||
|
// the same as gzgets
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
while (gzeof($h) === false) {
|
||||||
|
$count++;
|
||||||
|
echo fgetc( $h );
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\ncharacters counted=$count\n";
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
|
||||||
|
characters counted=176
|
||||||
|
===DONE===
|
29
ext/zlib/tests/gzgetc_error.phpt
Normal file
29
ext/zlib/tests/gzgetc_error.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzgetc() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzgetc( $h, $extra_arg ) );
|
||||||
|
|
||||||
|
var_dump(gzgetc() );
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzgetc() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzgetc() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
46
ext/zlib/tests/gzgets_basic.phpt
Normal file
46
ext/zlib/tests/gzgets_basic.phpt
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzgets() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// note that gzgets is an alias to fgets. parameter checking tests will be
|
||||||
|
// the same as fgets
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$lengths = array(10, 14, 7, 99);
|
||||||
|
foreach ($lengths as $length) {
|
||||||
|
var_dump(gzgets( $h, $length ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
while (gzeof($h) === false) {
|
||||||
|
var_dump(gzgets($h));
|
||||||
|
}
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
string(9) "When you'"
|
||||||
|
string(13) "re taught thr"
|
||||||
|
string(6) "ough f"
|
||||||
|
string(8) "eelings
|
||||||
|
"
|
||||||
|
string(26) "Destiny flying high above
|
||||||
|
"
|
||||||
|
string(38) "all I know is that you can realize it
|
||||||
|
"
|
||||||
|
string(18) "Destiny who cares
|
||||||
|
"
|
||||||
|
string(19) "as it turns around
|
||||||
|
"
|
||||||
|
string(39) "and I know that it descends down on me
|
||||||
|
"
|
||||||
|
===DONE===
|
30
ext/zlib/tests/gzgets_error.phpt
Normal file
30
ext/zlib/tests/gzgets_error.phpt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzgets() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$length = 10;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzgets( $h, $length, $extra_arg ) );
|
||||||
|
|
||||||
|
var_dump(gzgets());
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzgets() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzgets() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
51
ext/zlib/tests/gzopen_basic.phpt
Normal file
51
ext/zlib/tests/gzopen_basic.phpt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : basic functionality ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Initialise all required variables
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$mode = 'r';
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
// Calling gzopen() with all possible arguments
|
||||||
|
$h = gzopen($filename, $mode, $use_include_path);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
// Calling gzopen() with mandatory arguments
|
||||||
|
$h = gzopen($filename, $mode);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : basic functionality ***
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
===DONE===
|
52
ext/zlib/tests/gzopen_basic2.phpt
Normal file
52
ext/zlib/tests/gzopen_basic2.phpt
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : basic functionality for writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : basic functionality ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Initialise all required variables
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$modes = array('w', 'w+');
|
||||||
|
$data = b"This was the information that was written";
|
||||||
|
|
||||||
|
foreach($modes as $mode) {
|
||||||
|
echo "testing mode -- $mode --\n";
|
||||||
|
$h = gzopen($filename, $mode);
|
||||||
|
if ($h !== false) {
|
||||||
|
gzwrite($h, $data);
|
||||||
|
gzclose($h);
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var_dump($h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : basic functionality ***
|
||||||
|
testing mode -- w --
|
||||||
|
This was the information that was written
|
||||||
|
testing mode -- w+ --
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
47
ext/zlib/tests/gzopen_error.phpt
Normal file
47
ext/zlib/tests/gzopen_error.phpt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : error conditions
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
//Test gzopen with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing gzopen() function with more than expected no. of arguments --\n";
|
||||||
|
$filename = 'string_val';
|
||||||
|
$mode = 'string_val';
|
||||||
|
$use_include_path = 10;
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( gzopen($filename, $mode, $use_include_path, $extra_arg) );
|
||||||
|
|
||||||
|
// Testing gzopen with one less than the expected number of arguments
|
||||||
|
echo "\n-- Testing gzopen() function with less than expected no. of arguments --\n";
|
||||||
|
$filename = 'string_val';
|
||||||
|
var_dump( gzopen($filename) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing gzopen() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: gzopen() expects at most 3 parameters, 4 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing gzopen() function with less than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: gzopen() expects at least 2 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
92
ext/zlib/tests/gzopen_include_path.inc
Normal file
92
ext/zlib/tests/gzopen_include_path.inc
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
$pwd = getcwd();
|
||||||
|
$f = basename(__FILE__);
|
||||||
|
$dir1 = $pwd."/".$f.".dir1";
|
||||||
|
$dir2 = $pwd."/".$f.".dir2";
|
||||||
|
$dir3 = $pwd."/".$f.".dir3";
|
||||||
|
//invalid directory
|
||||||
|
$dir4 = $pwd."/".$f.".dir4";
|
||||||
|
$newdirs = array($dir1, $dir2, $dir3);
|
||||||
|
|
||||||
|
$reldirs = array("dir1", "dir2", "dir3");
|
||||||
|
|
||||||
|
function generate_next_rel_path() {
|
||||||
|
global $reldirs;
|
||||||
|
//create the include directory structure
|
||||||
|
$pathSep = ":";
|
||||||
|
$newIncludePath = "";
|
||||||
|
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
$pathSep = ";";
|
||||||
|
}
|
||||||
|
foreach($reldirs as $newdir) {
|
||||||
|
$newIncludePath .= $newdir.$pathSep;
|
||||||
|
}
|
||||||
|
return "dir4".$pathSep . $newIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_next_path() {
|
||||||
|
global $newdirs, $dir4;
|
||||||
|
//create the include directory structure
|
||||||
|
$pathSep = ":";
|
||||||
|
$newIncludePath = "";
|
||||||
|
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
$pathSep = ";";
|
||||||
|
}
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
$newIncludePath .= $newdir.$pathSep;
|
||||||
|
}
|
||||||
|
return $dir4.$pathSep . $newIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function create_include_path() {
|
||||||
|
|
||||||
|
global $newdirs;
|
||||||
|
//create the include directory structure
|
||||||
|
$pathSep = ":";
|
||||||
|
$newIncludePath = "";
|
||||||
|
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
$pathSep = ";";
|
||||||
|
}
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
mkdir($newdir);
|
||||||
|
$newIncludePath .= $newdir.$pathSep;
|
||||||
|
}
|
||||||
|
return $newIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
function relative_include_path() {
|
||||||
|
|
||||||
|
global $reldirs;
|
||||||
|
//create the include directory structure
|
||||||
|
$pathSep = ":";
|
||||||
|
$newIncludePath = "";
|
||||||
|
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
$pathSep = ";";
|
||||||
|
}
|
||||||
|
foreach($reldirs as $newdir) {
|
||||||
|
mkdir($newdir);
|
||||||
|
$newIncludePath .= $newdir.$pathSep;
|
||||||
|
}
|
||||||
|
return $newIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function teardown_include_path() {
|
||||||
|
|
||||||
|
global $newdirs;
|
||||||
|
// remove the directory structure
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
rmdir($newdir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown_relative_path() {
|
||||||
|
|
||||||
|
global $reldirs;
|
||||||
|
// remove the directory structure
|
||||||
|
foreach($reldirs as $newdir) {
|
||||||
|
rmdir($newdir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
227
ext/zlib/tests/gzopen_variation1.phpt
Normal file
227
ext/zlib/tests/gzopen_variation1.phpt
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : usage variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - zlib extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : usage variation ***\n";
|
||||||
|
|
||||||
|
// Define error handler
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
$mode = 'r';
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// define some classes
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// add arrays
|
||||||
|
$index_array = array (1, 2, 3);
|
||||||
|
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
|
||||||
|
// null data
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
|
||||||
|
// object data
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
'resource' => $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for filename
|
||||||
|
|
||||||
|
foreach($inputs as $key =>$value) {
|
||||||
|
echo "\n--$key--\n";
|
||||||
|
var_dump( gzopen($value, $mode, $use_include_path) );
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : usage variation ***
|
||||||
|
|
||||||
|
--int 0--
|
||||||
|
Error: 2 - gzopen(0): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int 1--
|
||||||
|
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int 12345--
|
||||||
|
Error: 2 - gzopen(12345): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int -12345--
|
||||||
|
Error: 2 - gzopen(-2345): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 10.5--
|
||||||
|
Error: 2 - gzopen(10.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float -10.5--
|
||||||
|
Error: 2 - gzopen(-10.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 12.3456789000e10--
|
||||||
|
Error: 2 - gzopen(123456789000): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float -12.3456789000e10--
|
||||||
|
Error: 2 - gzopen(-123456789000): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float .5--
|
||||||
|
Error: 2 - gzopen(0.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty array--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--int indexed array--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--associative array--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--nested arrays--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--uppercase NULL--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase null--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase true--
|
||||||
|
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase false--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--uppercase TRUE--
|
||||||
|
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--uppercase FALSE--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string DQ--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string SQ--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithToString--
|
||||||
|
Error: 2 - gzopen(Class A object): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithoutToString--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--undefined var--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--unset var--
|
||||||
|
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--resource--
|
||||||
|
Error: 2 - gzopen() expects parameter 1 to be string (Unicode or binary), resource given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
227
ext/zlib/tests/gzopen_variation2.phpt
Normal file
227
ext/zlib/tests/gzopen_variation2.phpt
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : usage variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - zlib extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : usage variation ***\n";
|
||||||
|
|
||||||
|
// Define error handler
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// define some classes
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// add arrays
|
||||||
|
$index_array = array (1, 2, 3);
|
||||||
|
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
|
||||||
|
// null data
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
|
||||||
|
// object data
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
'resource' => $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for mode
|
||||||
|
|
||||||
|
foreach($inputs as $key =>$value) {
|
||||||
|
echo "\n--$key--\n";
|
||||||
|
var_dump( gzopen($filename, $value, $use_include_path) );
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : usage variation ***
|
||||||
|
|
||||||
|
--int 0--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int 1--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int 12345--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--int -12345--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 10.5--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float -10.5--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 12.3456789000e10--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float -12.3456789000e10--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float .5--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty array--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--int indexed array--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--associative array--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--nested arrays--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--uppercase NULL--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase null--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase true--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase false--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--uppercase TRUE--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--uppercase FALSE--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string DQ--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string SQ--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithToString--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithoutToString--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--undefined var--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--unset var--
|
||||||
|
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--resource--
|
||||||
|
Error: 2 - gzopen() expects parameter 2 to be binary string, resource given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
218
ext/zlib/tests/gzopen_variation3.phpt
Normal file
218
ext/zlib/tests/gzopen_variation3.phpt
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : usage variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - zlib extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : usage variation ***\n";
|
||||||
|
|
||||||
|
// Define error handler
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$mode = 'r';
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// define some classes
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// add arrays
|
||||||
|
$index_array = array (1, 2, 3);
|
||||||
|
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// float data
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
|
||||||
|
// null data
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
|
||||||
|
// string data
|
||||||
|
'string DQ' => "string",
|
||||||
|
'string SQ' => 'string',
|
||||||
|
'mixed case string' => "sTrInG",
|
||||||
|
'heredoc' => $heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
'resource' => $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for use_include_path
|
||||||
|
|
||||||
|
foreach($inputs as $key =>$value) {
|
||||||
|
echo "\n--$key--\n";
|
||||||
|
$res = gzopen($filename, $mode, $value);
|
||||||
|
var_dump($res);
|
||||||
|
if ($res === true) {
|
||||||
|
gzclose($res);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : usage variation ***
|
||||||
|
|
||||||
|
--float 10.5--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--float -10.5--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--float 12.3456789000e10--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--float -12.3456789000e10--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--float .5--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--empty array--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--int indexed array--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--associative array--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--nested arrays--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--uppercase NULL--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--lowercase null--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--lowercase true--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--lowercase false--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--uppercase TRUE--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--uppercase FALSE--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--empty string DQ--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--empty string SQ--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--string DQ--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--string SQ--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--mixed case string--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--heredoc--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, Unicode string given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--instance of classWithToString--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--instance of classWithoutToString--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--undefined var--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--unset var--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
--resource--
|
||||||
|
Error: 2 - gzopen() expects parameter 3 to be long, resource given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
191
ext/zlib/tests/gzopen_variation4.phpt
Normal file
191
ext/zlib/tests/gzopen_variation4.phpt
Normal file
|
@ -0,0 +1,191 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : variation: use include path (relative directories in path)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : usage variation ***\n";
|
||||||
|
|
||||||
|
require_once('reading_include_path.inc');
|
||||||
|
|
||||||
|
//define the files to go into these directories, create one in dir2
|
||||||
|
echo "\n--- testing include path ---\n";
|
||||||
|
set_include_path($newIncludePath);
|
||||||
|
$modes = array("r", "r+", "rt");
|
||||||
|
foreach($modes as $mode) {
|
||||||
|
test_gzopen($mode);
|
||||||
|
}
|
||||||
|
restore_include_path();
|
||||||
|
|
||||||
|
// remove the directory structure
|
||||||
|
chdir($baseDir);
|
||||||
|
rmdir($workingDir);
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
rmdir($newdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir("..");
|
||||||
|
rmdir($thisTestDir);
|
||||||
|
|
||||||
|
function test_gzopen($mode) {
|
||||||
|
global $scriptFile, $secondFile, $firstFile, $filename;
|
||||||
|
|
||||||
|
// create a file in the middle directory
|
||||||
|
$h = gzopen($secondFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir2");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
echo "\n** testing with mode=$mode **\n";
|
||||||
|
// should read dir2 file
|
||||||
|
$h = gzopen($filename, $mode, true);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//create a file in dir1
|
||||||
|
$h = gzopen($firstFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir1");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should now read dir1 file
|
||||||
|
$h = gzopen($filename, $mode, true);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in working directory
|
||||||
|
$h = gzopen($filename, "w");
|
||||||
|
gzwrite($h, b"This is a file in working dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should still read dir1 file
|
||||||
|
$h = gzopen($filename, $mode, true);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
unlink($firstFile);
|
||||||
|
unlink($secondFile);
|
||||||
|
|
||||||
|
//should read the file in working dir
|
||||||
|
$h = gzopen($filename, $mode, true);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in the script directory
|
||||||
|
$h = gzopen($scriptFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in script dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should read the file in script dir
|
||||||
|
$h = gzopen($filename, $mode, true);
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//cleanup
|
||||||
|
unlink($filename);
|
||||||
|
unlink($scriptFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : usage variation ***
|
||||||
|
|
||||||
|
--- testing include path ---
|
||||||
|
|
||||||
|
** testing with mode=r **
|
||||||
|
This is a file in dir2
|
||||||
|
This is a file in dir1
|
||||||
|
This is a file in dir1
|
||||||
|
This is a file in working dir
|
||||||
|
This is a file in script dir
|
||||||
|
|
||||||
|
** testing with mode=r+ **
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
** testing with mode=rt **
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot cast a filtered stream on this system in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot cast a filtered stream on this system in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot cast a filtered stream on this system in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot cast a filtered stream on this system in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
|
||||||
|
Warning: gzopen(): cannot cast a filtered stream on this system in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||||
|
|
||||||
|
===DONE===
|
||||||
|
|
71
ext/zlib/tests/gzopen_variation5.phpt
Normal file
71
ext/zlib/tests/gzopen_variation5.phpt
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : variation: use include path and stream context create a file, relative path
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('gzopen_include_path.inc');
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : variation ***\n";
|
||||||
|
$thisTestDir = "gzopenVariation5.dir";
|
||||||
|
mkdir($thisTestDir);
|
||||||
|
chdir($thisTestDir);
|
||||||
|
|
||||||
|
$newpath = relative_include_path();
|
||||||
|
set_include_path($newpath);
|
||||||
|
runtest();
|
||||||
|
$newpath = generate_next_rel_path();
|
||||||
|
set_include_path($newpath);
|
||||||
|
runtest();
|
||||||
|
|
||||||
|
teardown_relative_path();
|
||||||
|
restore_include_path();
|
||||||
|
chdir("..");
|
||||||
|
rmdir($thisTestDir);
|
||||||
|
|
||||||
|
function runtest() {
|
||||||
|
$tmpfile = 'gzopen_variation5.tmp';
|
||||||
|
$h = gzopen($tmpfile, "w", true);
|
||||||
|
fwrite($h, b"This is the test file");
|
||||||
|
fclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
$h = @gzopen($tmpfile, "r");
|
||||||
|
if ($h === false) {
|
||||||
|
echo "Not created in working dir\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "created in working dir\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink($tmpfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$h = @gzopen('dir1/'.$tmpfile, "r");
|
||||||
|
if ($h === false) {
|
||||||
|
echo "Not created in dir1\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "created in dir1\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink('dir1/'.$tmpfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing gzopen() : variation ***
|
||||||
|
created in working dir
|
||||||
|
Not created in dir1
|
||||||
|
created in working dir
|
||||||
|
Not created in dir1
|
||||||
|
===DONE===
|
47
ext/zlib/tests/gzopen_variation6.phpt
Normal file
47
ext/zlib/tests/gzopen_variation6.phpt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
--TEST--
|
||||||
|
Test gzopen() function : variation: relative/absolute file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
|
* Source code: ext/zlib/zlib.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing gzopen() : variation ***\n";
|
||||||
|
$absfile = __FILE__.'.tmp';
|
||||||
|
$relfile = "gzopen_variation6.tmp";
|
||||||
|
|
||||||
|
$h = gzopen($absfile, "w");
|
||||||
|
gzwrite($h, b"This is an absolute file");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($relfile, "w");
|
||||||
|
gzwrite($h, b"This is a relative file");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($absfile, "r");
|
||||||
|
gzpassthru($h);
|
||||||
|
fclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
$h = gzopen($relfile, "r");
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
unlink($absfile);
|
||||||
|
unlink($relfile);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing gzopen() : variation ***
|
||||||
|
This is an absolute file
|
||||||
|
This is a relative file
|
||||||
|
===DONE===
|
31
ext/zlib/tests/gzopen_variation7.phpt
Normal file
31
ext/zlib/tests/gzopen_variation7.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzopen() by calling it twice on the same file and not closing one of them at the end of the script
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h1 = gzopen($f, 'r');
|
||||||
|
$h2 = gzopen($f, 'r');
|
||||||
|
|
||||||
|
var_dump(gzread($h1, 30));
|
||||||
|
var_dump(gzread($h2, 10));
|
||||||
|
var_dump(gzread($h1, 15));
|
||||||
|
gzclose($h1);
|
||||||
|
var_dump(gzread($h2, 50));
|
||||||
|
// deliberately do not close $h2
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
string(30) "When you're taught through fee"
|
||||||
|
string(10) "When you'r"
|
||||||
|
string(15) "lings
|
||||||
|
Destiny f"
|
||||||
|
string(50) "e taught through feelings
|
||||||
|
Destiny flying high abov"
|
||||||
|
===DONE===
|
32
ext/zlib/tests/gzpassthru_basic.phpt
Normal file
32
ext/zlib/tests/gzpassthru_basic.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzpassthru() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// note that gzpassthru is an alias to fpassthru. parameter checking tests will be
|
||||||
|
// the same as fpassthru
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
var_dump(gzpassthru($h));
|
||||||
|
var_dump(gzpassthru($h));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
int(0)
|
||||||
|
===DONE===
|
29
ext/zlib/tests/gzpassthru_error.phpt
Normal file
29
ext/zlib/tests/gzpassthru_error.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzpassthru() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzpassthru( $h, $extra_arg ) );
|
||||||
|
var_dump(gzpassthru() );
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzpassthru() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
31
ext/zlib/tests/gzputs_basic.phpt
Normal file
31
ext/zlib/tests/gzputs_basic.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzputs() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
$length = 10;
|
||||||
|
var_dump(gzputs( $h, $str ) );
|
||||||
|
var_dump(gzputs( $h, $str, $length ) );
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(34)
|
||||||
|
int(10)
|
||||||
|
Here is the string to be written. Here is th
|
||||||
|
===DONE===
|
37
ext/zlib/tests/gzread_basic.phpt
Normal file
37
ext/zlib/tests/gzread_basic.phpt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzread() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// note that gzread is an alias to fread. parameter checking tests will be
|
||||||
|
// the same as fread
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$lengths = array(10, 14, 7, 99, 2000);
|
||||||
|
|
||||||
|
foreach ($lengths as $length) {
|
||||||
|
var_dump(gzread( $h, $length ) );
|
||||||
|
}
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
string(10) "When you'r"
|
||||||
|
string(14) "e taught throu"
|
||||||
|
string(7) "gh feel"
|
||||||
|
string(99) "ings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns "
|
||||||
|
string(46) "around
|
||||||
|
and I know that it descends down on me
|
||||||
|
"
|
||||||
|
===DONE===
|
32
ext/zlib/tests/gzread_error.phpt
Normal file
32
ext/zlib/tests/gzread_error.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzread() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$length = 10;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
|
||||||
|
var_dump(gzread( $h, $length, $extra_arg ) );
|
||||||
|
|
||||||
|
var_dump(gzread());
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzread() expects exactly 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzread() expects exactly 2 parameters, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
32
ext/zlib/tests/gzread_error2.phpt
Normal file
32
ext/zlib/tests/gzread_error2.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzread() by calling it invalid lengths
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
var_dump(gzread($h, 0));
|
||||||
|
var_dump(gzread($h, 5));
|
||||||
|
var_dump(gzread($h, -1));
|
||||||
|
var_dump(gzread($h, 8));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
string(10) "When you'r"
|
||||||
|
|
||||||
|
Warning: gzread(): Length parameter must be greater than 0 in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(5) "e tau"
|
||||||
|
|
||||||
|
Warning: gzread(): Length parameter must be greater than 0 in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(8) "ght thro"
|
||||||
|
===DONE===
|
34
ext/zlib/tests/gzread_variation1.phpt
Normal file
34
ext/zlib/tests/gzread_variation1.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzread() by calling it while file open for writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
var_dump(gzread($h, 100));
|
||||||
|
gzwrite( $h, $str);
|
||||||
|
var_dump(gzread($h, 100));
|
||||||
|
gzrewind($h);
|
||||||
|
var_dump(gzread($h, 100));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
string(0) ""
|
||||||
|
string(0) ""
|
||||||
|
string(0) ""
|
||||||
|
Here is the string to be written.
|
||||||
|
===DONE===
|
36
ext/zlib/tests/gzrewind_basic.phpt
Normal file
36
ext/zlib/tests/gzrewind_basic.phpt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzrewind() by calling it with its expected arguments when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo "test rewind before doing anything\n";
|
||||||
|
var_dump(gzrewind($h));
|
||||||
|
var_dump(gztell($h));
|
||||||
|
echo "\nfirst 30 characters=".gzread($h, 30)."\n";
|
||||||
|
var_dump(gztell($h));
|
||||||
|
gzrewind($h);
|
||||||
|
var_dump(gztell($h));
|
||||||
|
echo "first 10 characters=".gzread($h, 10)."\n";
|
||||||
|
gzrewind($h);
|
||||||
|
echo "first 20 characters=".gzread($h, 20)."\n";
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
test rewind before doing anything
|
||||||
|
bool(true)
|
||||||
|
int(0)
|
||||||
|
|
||||||
|
first 30 characters=When you're taught through fee
|
||||||
|
int(30)
|
||||||
|
int(0)
|
||||||
|
first 10 characters=When you'r
|
||||||
|
first 20 characters=When you're taught t
|
||||||
|
===DONE===
|
34
ext/zlib/tests/gzrewind_basic2.phpt
Normal file
34
ext/zlib/tests/gzrewind_basic2.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzrewind() by calling it with its expected arguments when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
|
||||||
|
// read to the end of the file
|
||||||
|
echo "read to the end of the file, then rewind\n";
|
||||||
|
gzread($h, 10000);
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
var_dump(gztell($h));
|
||||||
|
gzrewind($h);
|
||||||
|
var_dump(gzeof($h));
|
||||||
|
var_dump(gztell($h));
|
||||||
|
echo "first 20 characters=".gzread($h,20)."\n";
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
read to the end of the file, then rewind
|
||||||
|
bool(true)
|
||||||
|
int(176)
|
||||||
|
bool(false)
|
||||||
|
int(0)
|
||||||
|
first 20 characters=When you're taught t
|
||||||
|
===DONE===
|
27
ext/zlib/tests/gzrewind_error.phpt
Normal file
27
ext/zlib/tests/gzrewind_error.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzrewind() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzrewind( $h, $extra_arg ) );
|
||||||
|
var_dump(gzrewind());
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: gzrewind() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzrewind() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
28
ext/zlib/tests/gzrewind_variation1.phpt
Normal file
28
ext/zlib/tests/gzrewind_variation1.phpt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzrewind() by calling it with its expected arguments when writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp2.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
gzwrite($h, b'The first string.');
|
||||||
|
var_dump(gzrewind($h));
|
||||||
|
gzwrite($h, b'The second string.');
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
echo "\n";
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
The first string.The second string.
|
||||||
|
===DONE===
|
49
ext/zlib/tests/gzseek_basic.phpt
Normal file
49
ext/zlib/tests/gzseek_basic.phpt
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with its expected arguments when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
|
||||||
|
echo "move to the 50th byte\n";
|
||||||
|
var_dump(gzseek( $h, 50 ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove forward to the 100th byte\n";
|
||||||
|
var_dump(gzseek( $h, 100 ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove backward to the 20th byte\n";
|
||||||
|
var_dump(gzseek( $h, 20 ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
move to the 50th byte
|
||||||
|
int(0)
|
||||||
|
tell=50
|
||||||
|
string(10) " high abov"
|
||||||
|
|
||||||
|
move forward to the 100th byte
|
||||||
|
int(0)
|
||||||
|
tell=100
|
||||||
|
string(10) "Destiny wh"
|
||||||
|
|
||||||
|
move backward to the 20th byte
|
||||||
|
int(0)
|
||||||
|
tell=20
|
||||||
|
string(10) "hrough fee"
|
||||||
|
===DONE===
|
42
ext/zlib/tests/gzseek_basic2.phpt
Normal file
42
ext/zlib/tests/gzseek_basic2.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with its expected arguments when writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp3.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
$str1 = b"This is the first line.";
|
||||||
|
$str2 = b"This is the second line.";
|
||||||
|
gzwrite($h, $str1);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
|
||||||
|
//seek forwards 20 bytes.
|
||||||
|
gzseek($h, strlen($str1) + 20);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzwrite($h, $str2);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzclose($h);
|
||||||
|
echo "\nreading the output file\n";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo gzread($h, strlen($str1))."\n";
|
||||||
|
echo var_dump(bin2hex(gzread($h, 20)));
|
||||||
|
echo gzread($h, strlen($str2))."\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
tell=23
|
||||||
|
tell=43
|
||||||
|
tell=67
|
||||||
|
|
||||||
|
reading the output file
|
||||||
|
This is the first line.
|
||||||
|
unicode(40) "0000000000000000000000000000000000000000"
|
||||||
|
This is the second line.
|
||||||
|
===DONE===
|
33
ext/zlib/tests/gzseek_error.phpt
Normal file
33
ext/zlib/tests/gzseek_error.phpt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$offset = 1;
|
||||||
|
$whence = SEEK_SET;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
|
||||||
|
var_dump(gzseek( $h, $offset, $whence, $extra_arg ) );
|
||||||
|
var_dump(gzseek($h));
|
||||||
|
var_dump(gzseek());
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzseek() expects at most 3 parameters, 4 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzseek() expects at least 2 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzseek() expects at least 2 parameters, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
33
ext/zlib/tests/gzseek_variation1.phpt
Normal file
33
ext/zlib/tests/gzseek_variation1.phpt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by seeking forward in write mode
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp3.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
$str1 = b"This is the first line.";
|
||||||
|
$str2 = b"This is the second line.";
|
||||||
|
gzwrite($h, $str1);
|
||||||
|
|
||||||
|
//seek forwards 20 bytes.
|
||||||
|
gzseek($h, strlen($str1) + 20);
|
||||||
|
gzwrite($h, $str2);
|
||||||
|
gzclose($h);
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo gzread($h, strlen($str1))."\n";
|
||||||
|
echo var_dump(bin2hex(gzread($h, 20)));
|
||||||
|
echo gzread($h, strlen($str2))."\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
This is the first line.
|
||||||
|
unicode(40) "0000000000000000000000000000000000000000"
|
||||||
|
This is the second line.
|
||||||
|
===DONE===
|
49
ext/zlib/tests/gzseek_variation2.phpt
Normal file
49
ext/zlib/tests/gzseek_variation2.phpt
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with SEEK_SET when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
|
||||||
|
echo "move to the 50th byte\n";
|
||||||
|
var_dump(gzseek( $h, 50, SEEK_SET ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove forward to the 100th byte\n";
|
||||||
|
var_dump(gzseek( $h, 100, SEEK_SET ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove backward to the 20th byte\n";
|
||||||
|
var_dump(gzseek( $h, 20, SEEK_SET ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
move to the 50th byte
|
||||||
|
int(0)
|
||||||
|
tell=50
|
||||||
|
string(10) " high abov"
|
||||||
|
|
||||||
|
move forward to the 100th byte
|
||||||
|
int(0)
|
||||||
|
tell=100
|
||||||
|
string(10) "Destiny wh"
|
||||||
|
|
||||||
|
move backward to the 20th byte
|
||||||
|
int(0)
|
||||||
|
tell=20
|
||||||
|
string(10) "hrough fee"
|
||||||
|
===DONE===
|
50
ext/zlib/tests/gzseek_variation3.phpt
Normal file
50
ext/zlib/tests/gzseek_variation3.phpt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with SEEK_CUR when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
|
||||||
|
echo "move to the 50th byte\n";
|
||||||
|
var_dump(gzseek( $h, 50, SEEK_CUR ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove forward to the 94th byte\n";
|
||||||
|
var_dump(gzseek( $h, 34, SEEK_CUR ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
|
||||||
|
echo "\nmove backward to the 77th byte\n";
|
||||||
|
var_dump(gzseek( $h, -27, SEEK_CUR ) );
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
//read the next 10
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
move to the 50th byte
|
||||||
|
int(0)
|
||||||
|
tell=50
|
||||||
|
string(10) " high abov"
|
||||||
|
|
||||||
|
move forward to the 94th byte
|
||||||
|
int(0)
|
||||||
|
tell=94
|
||||||
|
string(10) "ze it
|
||||||
|
Dest"
|
||||||
|
|
||||||
|
move backward to the 77th byte
|
||||||
|
int(0)
|
||||||
|
tell=77
|
||||||
|
string(10) "hat you ca"
|
||||||
|
===DONE===
|
42
ext/zlib/tests/gzseek_variation4.phpt
Normal file
42
ext/zlib/tests/gzseek_variation4.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with SEEK_SET when writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp3.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
$str1 = b"This is the first line.";
|
||||||
|
$str2 = b"This is the second line.";
|
||||||
|
gzwrite($h, $str1);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
|
||||||
|
//seek forwards 20 bytes.
|
||||||
|
gzseek($h, strlen($str1) + 20, SEEK_SET);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzwrite($h, $str2);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzclose($h);
|
||||||
|
echo "\nreading the output file\n";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo gzread($h, strlen($str1))."\n";
|
||||||
|
echo var_dump(bin2hex(gzread($h, 20)));
|
||||||
|
echo gzread($h, strlen($str2))."\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
tell=23
|
||||||
|
tell=43
|
||||||
|
tell=67
|
||||||
|
|
||||||
|
reading the output file
|
||||||
|
This is the first line.
|
||||||
|
unicode(40) "0000000000000000000000000000000000000000"
|
||||||
|
This is the second line.
|
||||||
|
===DONE===
|
42
ext/zlib/tests/gzseek_variation5.phpt
Normal file
42
ext/zlib/tests/gzseek_variation5.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzseek() by calling it with SEEK_CUR when writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp3.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
$str1 = b"This is the first line.";
|
||||||
|
$str2 = b"This is the second line.";
|
||||||
|
gzwrite($h, $str1);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
|
||||||
|
//seek forwards 20 bytes.
|
||||||
|
gzseek($h, 20, SEEK_CUR);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzwrite($h, $str2);
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
gzclose($h);
|
||||||
|
echo "\nreading the output file\n";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
echo gzread($h, strlen($str1))."\n";
|
||||||
|
echo var_dump(bin2hex(gzread($h, 20)));
|
||||||
|
echo gzread($h, strlen($str2))."\n";
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
tell=23
|
||||||
|
tell=43
|
||||||
|
tell=67
|
||||||
|
|
||||||
|
reading the output file
|
||||||
|
This is the first line.
|
||||||
|
unicode(40) "0000000000000000000000000000000000000000"
|
||||||
|
This is the second line.
|
||||||
|
===DONE===
|
34
ext/zlib/tests/gztell_basic.phpt
Normal file
34
ext/zlib/tests/gztell_basic.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gztell() by calling it with its expected arguments when reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$intervals = array(7, 22, 54, 17, 27, 15, 1000);
|
||||||
|
// tell should be 7, 29, 83, 100, 127, 142, 176 (176 is length of uncompressed file)
|
||||||
|
|
||||||
|
var_dump(gztell($h));
|
||||||
|
foreach ($intervals as $interval) {
|
||||||
|
gzread($h, $interval);
|
||||||
|
var_dump(gztell($h));
|
||||||
|
}
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(0)
|
||||||
|
int(7)
|
||||||
|
int(29)
|
||||||
|
int(83)
|
||||||
|
int(100)
|
||||||
|
int(127)
|
||||||
|
int(142)
|
||||||
|
int(176)
|
||||||
|
===DONE===
|
42
ext/zlib/tests/gztell_basic2.phpt
Normal file
42
ext/zlib/tests/gztell_basic2.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gztell() by calling it with its expected arguments when writing
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = "temp2.txt.gz";
|
||||||
|
$h = gzopen($f, 'w');
|
||||||
|
$sizes = array(7, 22, 54, 17, 27, 15, 1000);
|
||||||
|
// tell should be 7, 29, 83, 100, 127, 142, 1142
|
||||||
|
|
||||||
|
var_dump(gztell($h));
|
||||||
|
foreach ($sizes as $size) {
|
||||||
|
echo "bytes written=".gzwrite($h, str_repeat(b'1', $size))."\n";;
|
||||||
|
echo "tell=".gztell($h)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
unlink($f);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(0)
|
||||||
|
bytes written=7
|
||||||
|
tell=7
|
||||||
|
bytes written=22
|
||||||
|
tell=29
|
||||||
|
bytes written=54
|
||||||
|
tell=83
|
||||||
|
bytes written=17
|
||||||
|
tell=100
|
||||||
|
bytes written=27
|
||||||
|
tell=127
|
||||||
|
bytes written=15
|
||||||
|
tell=142
|
||||||
|
bytes written=1000
|
||||||
|
tell=1142
|
||||||
|
===DONE===
|
26
ext/zlib/tests/gztell_error.phpt
Normal file
26
ext/zlib/tests/gztell_error.phpt
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gztell() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f, 'r');
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gztell( $h, $extra_arg ) );
|
||||||
|
var_dump(gztell());
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gztell() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gztell() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
31
ext/zlib/tests/gzwrite_basic.phpt
Normal file
31
ext/zlib/tests/gzwrite_basic.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzwrite() by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
$length = 10;
|
||||||
|
var_dump(gzwrite( $h, $str ) );
|
||||||
|
var_dump(gzwrite( $h, $str, $length ) );
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(34)
|
||||||
|
int(10)
|
||||||
|
Here is the string to be written. Here is th
|
||||||
|
===DONE===
|
35
ext/zlib/tests/gzwrite_error.phpt
Normal file
35
ext/zlib/tests/gzwrite_error.phpt
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzwrite() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
$length = 10;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
var_dump(gzwrite($h, $str, $length, $extra_arg));
|
||||||
|
var_dump(gzwrite($h));
|
||||||
|
var_dump(gzwrite());
|
||||||
|
|
||||||
|
gzclose($h);
|
||||||
|
unlink($filename);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: gzwrite() expects at most 3 parameters, 4 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzwrite() expects at least 2 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: gzwrite() expects at least 2 parameters, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
30
ext/zlib/tests/gzwrite_error2.phpt
Normal file
30
ext/zlib/tests/gzwrite_error2.phpt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzwrite() by calling it invalid lengths
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
var_dump(gzwrite( $h, $str, 0 ) );
|
||||||
|
var_dump(gzwrite( $h, $str, -1 ) );
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(0)
|
||||||
|
int(0)
|
||||||
|
|
||||||
|
===DONE===
|
27
ext/zlib/tests/gzwrite_variation1.phpt
Normal file
27
ext/zlib/tests/gzwrite_variation1.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Test function gzwrite() by calling it when file is opened for reading
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
$str = b"Here is the string to be written. ";
|
||||||
|
$length = 10;
|
||||||
|
var_dump(gzwrite( $h, $str ) );
|
||||||
|
var_dump(gzread($h, 10));
|
||||||
|
var_dump(gzwrite( $h, $str, $length ) );
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(0)
|
||||||
|
string(10) "When you'r"
|
||||||
|
int(0)
|
||||||
|
===DONE===
|
34
ext/zlib/tests/readgzfile_basic.phpt
Normal file
34
ext/zlib/tests/readgzfile_basic.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() reading a gzip relative file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$plaintxt = b<<<EOT
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
$dirname = 'readgzfile_temp';
|
||||||
|
$filename = $dirname.'/plainfile.txt.gz';
|
||||||
|
mkdir($dirname);
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
gzwrite($h, $plaintxt);
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(readgzfile( $filename ) );
|
||||||
|
|
||||||
|
unlink($filename);
|
||||||
|
rmdir($dirname);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
int(52)
|
||||||
|
===DONE===
|
34
ext/zlib/tests/readgzfile_basic2.phpt
Normal file
34
ext/zlib/tests/readgzfile_basic2.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() reading a plain relative file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$plaintxt = b<<<EOT
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
$dirname = 'readgzfile_temp';
|
||||||
|
$filename = $dirname.'/plainfile.txt';
|
||||||
|
mkdir($dirname);
|
||||||
|
$h = fopen($filename, 'w');
|
||||||
|
fwrite($h, $plaintxt);
|
||||||
|
fclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
var_dump(readgzfile( $filename ) );
|
||||||
|
|
||||||
|
unlink($filename);
|
||||||
|
rmdir($dirname);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
hello world
|
||||||
|
is a very common test
|
||||||
|
for all languages
|
||||||
|
int(52)
|
||||||
|
===DONE===
|
29
ext/zlib/tests/readgzfile_error.phpt
Normal file
29
ext/zlib/tests/readgzfile_error.phpt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by calling it more than or less than its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$use_include_path = false;
|
||||||
|
$extra_arg = 'nothing';
|
||||||
|
|
||||||
|
var_dump(readgzfile( $filename, $use_include_path, $extra_arg ) );
|
||||||
|
|
||||||
|
var_dump(readgzfile( ) );
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: readgzfile() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
43
ext/zlib/tests/readgzfile_variation1.phpt
Normal file
43
ext/zlib/tests/readgzfile_variation1.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with array values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$index_array = array(1, 2, 3);
|
||||||
|
$assoc_array = array(1 => 'one', 2 => 'two');
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
67
ext/zlib/tests/readgzfile_variation10.phpt
Normal file
67
ext/zlib/tests/readgzfile_variation10.phpt
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with emptyUnsetUndefNull values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$unset_var = 10;
|
||||||
|
unset($unset_var);
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
===DONE===
|
64
ext/zlib/tests/readgzfile_variation11.phpt
Normal file
64
ext/zlib/tests/readgzfile_variation11.phpt
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with float values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
===DONE===
|
56
ext/zlib/tests/readgzfile_variation12.phpt
Normal file
56
ext/zlib/tests/readgzfile_variation12.phpt
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with int values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array (
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
===DONE===
|
51
ext/zlib/tests/readgzfile_variation13.phpt
Normal file
51
ext/zlib/tests/readgzfile_variation13.phpt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with object values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Error: 2 - readgzfile() expects parameter 2 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
Error: 2 - readgzfile() expects parameter 2 to be long, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
44
ext/zlib/tests/readgzfile_variation14.phpt
Normal file
44
ext/zlib/tests/readgzfile_variation14.phpt
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with string values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$variation_array = array(
|
||||||
|
'string DQ' => "string",
|
||||||
|
'string SQ' => 'string',
|
||||||
|
'mixed case string' => "sTrInG",
|
||||||
|
'heredoc' => $heredoc
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation_array as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, Unicode string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
94
ext/zlib/tests/readgzfile_variation15.phpt
Normal file
94
ext/zlib/tests/readgzfile_variation15.phpt
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
--TEST--
|
||||||
|
Test readgzfile() function : variation: use include path (relative directories in path)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once('reading_include_path.inc');
|
||||||
|
|
||||||
|
//define the files to go into these directories, create one in dir2
|
||||||
|
set_include_path($newIncludePath);
|
||||||
|
test_readgzfile();
|
||||||
|
restore_include_path();
|
||||||
|
|
||||||
|
// remove the directory structure
|
||||||
|
chdir($baseDir);
|
||||||
|
rmdir($workingDir);
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
rmdir($newdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir("..");
|
||||||
|
rmdir($thisTestDir);
|
||||||
|
|
||||||
|
function test_readgzfile() {
|
||||||
|
global $scriptFile, $secondFile, $firstFile, $filename;
|
||||||
|
|
||||||
|
// create a file in the middle directory
|
||||||
|
$h = gzopen($secondFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir2");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
// should read dir2 file
|
||||||
|
echo "file content:";
|
||||||
|
readgzfile($filename, true);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//create a file in dir1
|
||||||
|
$h = gzopen($firstFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in dir1");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should now read dir1 file
|
||||||
|
echo "file content:";
|
||||||
|
readgzfile($filename, true);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in working directory
|
||||||
|
$h = gzopen($filename, "w");
|
||||||
|
gzwrite($h, b"This is a file in working dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should still read dir1 file
|
||||||
|
echo "file content:";
|
||||||
|
readgzfile($filename, true);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
unlink($firstFile);
|
||||||
|
unlink($secondFile);
|
||||||
|
|
||||||
|
//should read the file in working dir
|
||||||
|
echo "file content:";
|
||||||
|
readgzfile($filename, true);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
// create a file in the script directory
|
||||||
|
$h = gzopen($scriptFile, "w");
|
||||||
|
gzwrite($h, b"This is a file in script dir");
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
//should read the file in script dir
|
||||||
|
echo "file content:";
|
||||||
|
readgzfile($filename, true);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
//cleanup
|
||||||
|
unlink($filename);
|
||||||
|
unlink($scriptFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
file content:This is a file in dir2
|
||||||
|
file content:This is a file in dir1
|
||||||
|
file content:This is a file in dir1
|
||||||
|
file content:This is a file in working dir
|
||||||
|
file content:This is a file in script dir
|
||||||
|
===DONE===
|
||||||
|
|
40
ext/zlib/tests/readgzfile_variation2.phpt
Normal file
40
ext/zlib/tests/readgzfile_variation2.phpt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with boolean values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path =
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
50
ext/zlib/tests/readgzfile_variation3.phpt
Normal file
50
ext/zlib/tests/readgzfile_variation3.phpt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with emptyUnsetUndefNull values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$unset_var = 10;
|
||||||
|
unset($unset_var);
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'unset var' => @$unset_var,
|
||||||
|
'undefined var' => @$undefined_var,
|
||||||
|
'empty string DQ' => "",
|
||||||
|
'empty string SQ' => '',
|
||||||
|
'uppercase NULL' => NULL,
|
||||||
|
'lowercase null' => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(): Filename cannot be empty in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
43
ext/zlib/tests/readgzfile_variation4.phpt
Normal file
43
ext/zlib/tests/readgzfile_variation4.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with float values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded(zlib)) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'float 12.3456789000e10' => 12.3456789000e10,
|
||||||
|
'float -12.3456789000e10' => -12.3456789000e10,
|
||||||
|
'float .5' => .5,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: readgzfile(10.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(-10.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(-123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(0.5): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
39
ext/zlib/tests/readgzfile_variation5.phpt
Normal file
39
ext/zlib/tests/readgzfile_variation5.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with int values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$variation = array (
|
||||||
|
'int 0' => 0,
|
||||||
|
'int 1' => 1,
|
||||||
|
'int 12345' => 12345,
|
||||||
|
'int -12345' => -2345,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: readgzfile(0): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(1): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(12345): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(-2345): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
49
ext/zlib/tests/readgzfile_variation6.phpt
Normal file
49
ext/zlib/tests/readgzfile_variation6.phpt
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with object values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
if (error_reporting() != 0) {
|
||||||
|
// report non-silenced errors
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class classWithToString
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class classWithoutToString
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'instance of classWithToString' => new classWithToString(),
|
||||||
|
'instance of classWithoutToString' => new classWithoutToString(),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
Error: 2 - readgzfile() expects parameter 1 to be string (Unicode or binary), object given, %s(%d)
|
||||||
|
NULL
|
43
ext/zlib/tests/readgzfile_variation7.phpt
Normal file
43
ext/zlib/tests/readgzfile_variation7.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 1 with string values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$use_include_path = false;
|
||||||
|
|
||||||
|
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$variation_array = array(
|
||||||
|
'string DQ' => "string",
|
||||||
|
'string SQ' => 'string',
|
||||||
|
'mixed case string' => "sTrInG",
|
||||||
|
'heredoc' => $heredoc
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation_array as $var ) {
|
||||||
|
var_dump(readgzfile( $var , $use_include_path ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(sTrInG): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: readgzfile(hello world): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
43
ext/zlib/tests/readgzfile_variation8.phpt
Normal file
43
ext/zlib/tests/readgzfile_variation8.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with array values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
|
||||||
|
$index_array = array(1, 2, 3);
|
||||||
|
$assoc_array = array(1 => 'one', 2 => 'two');
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'empty array' => array(),
|
||||||
|
'int indexed array' => $index_array,
|
||||||
|
'associative array' => $assoc_array,
|
||||||
|
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: readgzfile() expects parameter 2 to be long, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
55
ext/zlib/tests/readgzfile_variation9.phpt
Normal file
55
ext/zlib/tests/readgzfile_variation9.phpt
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
--TEST--
|
||||||
|
Test function readgzfile() by substituting agument 2 with boolean values.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
|
||||||
|
$variation = array(
|
||||||
|
'lowercase true' => true,
|
||||||
|
'lowercase false' =>false,
|
||||||
|
'uppercase TRUE' =>TRUE,
|
||||||
|
'uppercase FALSE' =>FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ( $variation as $var ) {
|
||||||
|
var_dump(readgzfile( $filename, $var ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
When you're taught through feelings
|
||||||
|
Destiny flying high above
|
||||||
|
all I know is that you can realize it
|
||||||
|
Destiny who cares
|
||||||
|
as it turns around
|
||||||
|
and I know that it descends down on me
|
||||||
|
int(176)
|
||||||
|
===DONE===
|
27
ext/zlib/tests/reading_include_path.inc
Normal file
27
ext/zlib/tests/reading_include_path.inc
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
$thisTestDir = "zlibVariation.dir";
|
||||||
|
mkdir($thisTestDir);
|
||||||
|
chdir($thisTestDir);
|
||||||
|
|
||||||
|
//create the include directory structure
|
||||||
|
$workingDir = "workdir";
|
||||||
|
$filename = "afile.txt.gz";
|
||||||
|
$scriptDir = dirname(__FILE__);
|
||||||
|
$baseDir = getcwd();
|
||||||
|
$secondFile = $baseDir."/dir2/".$filename;
|
||||||
|
$firstFile = "../dir1/".$filename;
|
||||||
|
$scriptFile = $scriptDir.'/'.$filename;
|
||||||
|
|
||||||
|
$newdirs = array("dir1", "dir2", "dir3");
|
||||||
|
$pathSep = ":";
|
||||||
|
$newIncludePath = "";
|
||||||
|
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||||
|
$pathSep = ";";
|
||||||
|
}
|
||||||
|
foreach($newdirs as $newdir) {
|
||||||
|
mkdir($newdir);
|
||||||
|
$newIncludePath .= '../'.$newdir.$pathSep;
|
||||||
|
}
|
||||||
|
mkdir($workingDir);
|
||||||
|
chdir($workingDir);
|
||||||
|
?>
|
33
ext/zlib/tests/zlib_wrapper_fflush_basic.phpt
Normal file
33
ext/zlib/tests/zlib_wrapper_fflush_basic.phpt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
--TEST--
|
||||||
|
Test function fflush() on a zlib stream wrapper
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$filename = "temp.txt.gz";
|
||||||
|
$h = gzopen($filename, 'w');
|
||||||
|
$str = b"Here is the string to be written.";
|
||||||
|
$length = 10;
|
||||||
|
var_dump(fflush($h));
|
||||||
|
gzwrite( $h, $str);
|
||||||
|
gzwrite( $h, $str);
|
||||||
|
var_dump(fflush($h));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
$h = gzopen($filename, 'r');
|
||||||
|
gzpassthru($h);
|
||||||
|
gzclose($h);
|
||||||
|
echo "\n";
|
||||||
|
unlink($filename);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
Here is the string to be written.Here is the string to be written.
|
||||||
|
===DONE===
|
19
ext/zlib/tests/zlib_wrapper_flock_basic.phpt
Normal file
19
ext/zlib/tests/zlib_wrapper_flock_basic.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Test function stream_get_meta_data on a zlib stream
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f,'r');
|
||||||
|
var_dump(flock($h, LOCK_SH));
|
||||||
|
gzclose($h);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
32
ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt
Normal file
32
ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
Test function ftruncate() on zlib wrapper by calling it with its expected arguments
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$f2 = "temp.txt.gz";
|
||||||
|
copy($f, $f2);
|
||||||
|
|
||||||
|
$h = gzopen($f2, "r");
|
||||||
|
ftruncate($h, 20);
|
||||||
|
fclose($h);
|
||||||
|
unlink($f2);
|
||||||
|
|
||||||
|
$h = gzopen($f2, "w");
|
||||||
|
ftruncate($h, 20);
|
||||||
|
fclose($h);
|
||||||
|
unlink($f2);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: ftruncate(): Can't truncate this stream! in %s on line %d
|
||||||
|
|
||||||
|
Warning: ftruncate(): Can't truncate this stream! in %s on line %d
|
||||||
|
===DONE===
|
69
ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt
Normal file
69
ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
--TEST--
|
||||||
|
Test function stream_get_meta_data on a zlib stream
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded("zlib")) {
|
||||||
|
print "skip - ZLIB extension not loaded";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
echo "no wrapper\n";
|
||||||
|
$f = dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = gzopen($f,'r');
|
||||||
|
var_dump(stream_get_meta_data($h));
|
||||||
|
gzclose($h);
|
||||||
|
echo "\nwith wrapper\n";
|
||||||
|
$f = "compress.zlib://".dirname(__FILE__)."/004.txt.gz";
|
||||||
|
$h = fopen($f,'r');
|
||||||
|
var_dump(stream_get_meta_data($h));
|
||||||
|
gzclose($h);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
no wrapper
|
||||||
|
array(8) {
|
||||||
|
[u"stream_type"]=>
|
||||||
|
unicode(4) "ZLIB"
|
||||||
|
[u"mode"]=>
|
||||||
|
unicode(1) "r"
|
||||||
|
[u"unread_bytes"]=>
|
||||||
|
int(0)
|
||||||
|
[u"unread_chars"]=>
|
||||||
|
int(0)
|
||||||
|
[u"seekable"]=>
|
||||||
|
bool(true)
|
||||||
|
[u"timed_out"]=>
|
||||||
|
bool(false)
|
||||||
|
[u"blocked"]=>
|
||||||
|
bool(true)
|
||||||
|
[u"eof"]=>
|
||||||
|
bool(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
with wrapper
|
||||||
|
array(10) {
|
||||||
|
[u"wrapper_type"]=>
|
||||||
|
unicode(4) "ZLIB"
|
||||||
|
[u"stream_type"]=>
|
||||||
|
unicode(4) "ZLIB"
|
||||||
|
[u"mode"]=>
|
||||||
|
unicode(1) "r"
|
||||||
|
[u"unread_bytes"]=>
|
||||||
|
int(0)
|
||||||
|
[u"unread_chars"]=>
|
||||||
|
int(0)
|
||||||
|
[u"seekable"]=>
|
||||||
|
bool(true)
|
||||||
|
[u"uri"]=>
|
||||||
|
unicode(%d) "compress.zlib://%s/004.txt.gz"
|
||||||
|
[u"timed_out"]=>
|
||||||
|
bool(false)
|
||||||
|
[u"blocked"]=>
|
||||||
|
bool(true)
|
||||||
|
[u"eof"]=>
|
||||||
|
bool(false)
|
||||||
|
}
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue