mirror of
https://github.com/php/php-src.git
synced 2025-08-20 17:34:35 +02:00
various network tests. tested on windows, linux, linux 64 bit
This commit is contained in:
parent
3bda2b9689
commit
2a4fc75c54
20 changed files with 1472 additions and 0 deletions
23
ext/standard/tests/network/closelog_basic.phpt
Normal file
23
ext/standard/tests/network/closelog_basic.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
Test closelog() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool closelog(void)
|
||||||
|
* Description: Close connection to system logger
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing closelog() : basic functionality ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing closelog() function with Zero arguments --\n";
|
||||||
|
var_dump( closelog() );
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing closelog() : basic functionality ***
|
||||||
|
|
||||||
|
-- Testing closelog() function with Zero arguments --
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
27
ext/standard/tests/network/closelog_error.phpt
Normal file
27
ext/standard/tests/network/closelog_error.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Test closelog() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool closelog(void)
|
||||||
|
* Description: Close connection to system logger
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing closelog() : error conditions ***\n";
|
||||||
|
|
||||||
|
// One argument
|
||||||
|
echo "\n-- Testing closelog() function with one argument --\n";
|
||||||
|
$extra_arg = 10;;
|
||||||
|
var_dump( closelog($extra_arg) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing closelog() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing closelog() function with one argument --
|
||||||
|
|
||||||
|
Warning: closelog() expects exactly 0 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
|
@ -0,0 +1,107 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||||
|
die("skip Only run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : basic functionality ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables not defined
|
||||||
|
foreach($log_variables as $log_var) {
|
||||||
|
if (isset($$log_var)) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: variable defined\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump( define_syslog_variables() );
|
||||||
|
|
||||||
|
// show variables defined
|
||||||
|
for ($t = 0; $t < count($log_variables); $t++) {
|
||||||
|
if (isset($$log_variables[$t]) === false || $$log_variables[$t] != $log_constants[$t]) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: $log_variables[$t] doesn't contain the correct value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing define_syslog_variables() : basic functionality ***
|
||||||
|
|
||||||
|
Deprecated: Function define_syslog_variables() is deprecated in %s on line %d
|
||||||
|
NULL
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
126
ext/standard/tests/network/define_syslog_variables_basic.phpt
Normal file
126
ext/standard/tests/network/define_syslog_variables_basic.phpt
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) == "WIN")
|
||||||
|
die("skip don't run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : basic functionality ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
|
||||||
|
LOG_LOCAL0,
|
||||||
|
LOG_LOCAL1,
|
||||||
|
LOG_LOCAL2,
|
||||||
|
LOG_LOCAL3,
|
||||||
|
LOG_LOCAL4,
|
||||||
|
LOG_LOCAL5,
|
||||||
|
LOG_LOCAL6,
|
||||||
|
LOG_LOCAL7
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
|
||||||
|
"LOG_LOCAL0",
|
||||||
|
"LOG_LOCAL1",
|
||||||
|
"LOG_LOCAL2",
|
||||||
|
"LOG_LOCAL3",
|
||||||
|
"LOG_LOCAL4",
|
||||||
|
"LOG_LOCAL5",
|
||||||
|
"LOG_LOCAL6",
|
||||||
|
"LOG_LOCAL7"
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables not defined
|
||||||
|
foreach($log_variables as $log_var) {
|
||||||
|
if (isset($$log_var)) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: variable defined\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump( define_syslog_variables() );
|
||||||
|
|
||||||
|
// show variables now defined
|
||||||
|
for ($t = 0; $t < count($log_variables); $t++) {
|
||||||
|
if (isset($$log_variables[$t]) === false || $$log_variables[$t] != $log_constants[$t]) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: $log_variables[$t] doesn't contain the correct value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing define_syslog_variables() : basic functionality ***
|
||||||
|
|
||||||
|
Deprecated: Function define_syslog_variables() is deprecated in %s on line %d
|
||||||
|
NULL
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
|
@ -0,0 +1,29 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : error conditions ***\n";
|
||||||
|
|
||||||
|
// One argument
|
||||||
|
echo "\n-- Testing define_syslog_variables() function with one argument --\n";
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( define_syslog_variables($extra_arg) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing define_syslog_variables() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing define_syslog_variables() function with one argument --
|
||||||
|
|
||||||
|
Deprecated: Function define_syslog_variables() is deprecated in %s on line %d
|
||||||
|
|
||||||
|
Warning: define_syslog_variables() expects exactly 0 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
|
@ -0,0 +1,96 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : variation
|
||||||
|
--INI--
|
||||||
|
define_syslog_variables = true
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||||
|
die("skip Only run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : variation ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables defined
|
||||||
|
for ($t = 0; $t < count($log_variables); $t++) {
|
||||||
|
if (isset($$log_variables[$t]) === false || $$log_variables[$t] != $log_constants[$t]) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: $log_variables[$t] doesn't contain the correct value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing define_syslog_variables() : variation ***
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
|
@ -0,0 +1,96 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) == "WIN")
|
||||||
|
die("skip don't run on Windows");
|
||||||
|
?>
|
||||||
|
--INI--
|
||||||
|
define_syslog_variables = true
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : variation ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables defined
|
||||||
|
for ($t = 0; $t < count($log_variables); $t++) {
|
||||||
|
if (isset($$log_variables[$t]) === false || $$log_variables[$t] != $log_constants[$t]) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: $log_variables[$t] doesn't contain the correct value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing define_syslog_variables() : variation ***
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
|
@ -0,0 +1,96 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : variation
|
||||||
|
--INI--
|
||||||
|
define_syslog_variables = false
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||||
|
die("skip Only run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : variation ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables not defined
|
||||||
|
foreach($log_variables as $log_var) {
|
||||||
|
if (isset($$log_var)) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: variable defined\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing define_syslog_variables() : variation ***
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
|
@ -0,0 +1,96 @@
|
||||||
|
--TEST--
|
||||||
|
Test define_syslog_variables() function : variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) == "WIN")
|
||||||
|
die("skip don't run on Windows");
|
||||||
|
?>
|
||||||
|
--INI--
|
||||||
|
define_syslog_variables = false
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void define_syslog_variables(void)
|
||||||
|
* Description: Initializes all syslog-related variables
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing define_syslog_variables() : variation ***\n";
|
||||||
|
|
||||||
|
$log_constants = array(
|
||||||
|
LOG_EMERG,
|
||||||
|
LOG_ALERT,
|
||||||
|
LOG_CRIT,
|
||||||
|
LOG_ERR,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_NOTICE,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_KERN,
|
||||||
|
LOG_USER,
|
||||||
|
LOG_MAIL,
|
||||||
|
LOG_DAEMON,
|
||||||
|
LOG_AUTH,
|
||||||
|
LOG_SYSLOG,
|
||||||
|
LOG_LPR,
|
||||||
|
LOG_NEWS,
|
||||||
|
LOG_UUCP,
|
||||||
|
LOG_CRON,
|
||||||
|
LOG_AUTHPRIV,
|
||||||
|
LOG_PID,
|
||||||
|
LOG_CONS,
|
||||||
|
LOG_ODELAY,
|
||||||
|
LOG_NDELAY,
|
||||||
|
LOG_NOWAIT,
|
||||||
|
LOG_PERROR,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$log_variables = array(
|
||||||
|
"LOG_EMERG",
|
||||||
|
"LOG_ALERT",
|
||||||
|
"LOG_CRIT",
|
||||||
|
"LOG_ERR",
|
||||||
|
"LOG_WARNING",
|
||||||
|
"LOG_NOTICE",
|
||||||
|
"LOG_INFO",
|
||||||
|
"LOG_DEBUG",
|
||||||
|
"LOG_KERN",
|
||||||
|
"LOG_USER",
|
||||||
|
"LOG_MAIL",
|
||||||
|
"LOG_DAEMON",
|
||||||
|
"LOG_AUTH",
|
||||||
|
"LOG_SYSLOG",
|
||||||
|
"LOG_LPR",
|
||||||
|
"LOG_NEWS",
|
||||||
|
"LOG_UUCP",
|
||||||
|
"LOG_CRON",
|
||||||
|
"LOG_AUTHPRIV",
|
||||||
|
"LOG_PID",
|
||||||
|
"LOG_CONS",
|
||||||
|
"LOG_ODELAY",
|
||||||
|
"LOG_NDELAY",
|
||||||
|
"LOG_NOWAIT",
|
||||||
|
"LOG_PERROR",
|
||||||
|
);
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
// show variables not defined
|
||||||
|
foreach($log_variables as $log_var) {
|
||||||
|
if (isset($$log_var)) {
|
||||||
|
$failed = true;
|
||||||
|
echo "FAILED: variable defined\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed == false) {
|
||||||
|
echo "PASSED\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing define_syslog_variables() : variation ***
|
||||||
|
PASSED
|
||||||
|
===DONE===
|
54
ext/standard/tests/network/fsockopen_basic.phpt
Normal file
54
ext/standard/tests/network/fsockopen_basic.phpt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
--TEST--
|
||||||
|
Test fsockopen() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]])
|
||||||
|
* Description: Open Internet or Unix domain socket connection
|
||||||
|
* Source code: ext/standard/fsock.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing fsockopen() : basic functionality ***\n";
|
||||||
|
|
||||||
|
echo "Open a server socket\n";
|
||||||
|
$server = stream_socket_server('tcp://127.0.0.1:31337');
|
||||||
|
|
||||||
|
|
||||||
|
// Initialise all required variables
|
||||||
|
$hostname = 'tcp://127.0.0.1'; // loopback address
|
||||||
|
$port = 31337;
|
||||||
|
$errno = null;
|
||||||
|
$errstr = null;
|
||||||
|
$timeout = 1.5;
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() with all possible arguments:\n";
|
||||||
|
$client = fsockopen($hostname, $port, $errno, $errstr, $timeout);
|
||||||
|
var_dump($client);
|
||||||
|
fclose($client);
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() with mandatory arguments:\n";
|
||||||
|
$second_client = fsockopen($hostname, $port);
|
||||||
|
var_dump($second_client);
|
||||||
|
fclose($second_client);
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() with address and port in same string:\n";
|
||||||
|
$address = $hostname . ':' . $port;
|
||||||
|
$third_client = fsockopen($address);
|
||||||
|
var_dump($third_client);
|
||||||
|
fclose($third_client);
|
||||||
|
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing fsockopen() : basic functionality ***
|
||||||
|
Open a server socket
|
||||||
|
|
||||||
|
Calling fsockopen() with all possible arguments:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
Calling fsockopen() with mandatory arguments:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
Calling fsockopen() with address and port in same string:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
Done
|
75
ext/standard/tests/network/fsockopen_error.phpt
Normal file
75
ext/standard/tests/network/fsockopen_error.phpt
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
--TEST--
|
||||||
|
Test fsockopen() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]])
|
||||||
|
* Description: Open Internet or Unix domain socket connection
|
||||||
|
* Source code: ext/standard/fsock.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
echo "*** Testing fsockopen() : basic error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
echo "\n-- Testing fsockopen() function with more than expected no. of arguments --\n";
|
||||||
|
$hostname = 'string_val';
|
||||||
|
$port = 10;
|
||||||
|
$errno = 10;
|
||||||
|
$errstr = 'string_val';
|
||||||
|
$timeout = 10.5;
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout, $extra_arg) );
|
||||||
|
var_dump($errstr);
|
||||||
|
var_dump($errno);
|
||||||
|
|
||||||
|
echo "\n-- Testing fsockopen() function with less than expected no. of arguments --\n";
|
||||||
|
var_dump( fsockopen() );
|
||||||
|
|
||||||
|
echo "\n-- Attempting to connect to a non-existent socket --\n";
|
||||||
|
$hostname = 'tcp://127.0.0.1'; // loopback address
|
||||||
|
$port = 31337;
|
||||||
|
$errno = null;
|
||||||
|
$errstr = null;
|
||||||
|
$timeout = 1.5;
|
||||||
|
var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) );
|
||||||
|
var_dump($errstr);
|
||||||
|
|
||||||
|
echo "\n-- Attempting to connect using an invalid protocol --\n";
|
||||||
|
$hostname = 'invalid://127.0.0.1'; // loopback address
|
||||||
|
$port = 31337;
|
||||||
|
$errno = null;
|
||||||
|
$errstr = null;
|
||||||
|
$timeout = 1.5;
|
||||||
|
var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) );
|
||||||
|
var_dump($errstr);
|
||||||
|
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing fsockopen() : basic error conditions ***
|
||||||
|
|
||||||
|
-- Testing fsockopen() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: fsockopen() expects at most 5 parameters, 6 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(10) "string_val"
|
||||||
|
int(10)
|
||||||
|
|
||||||
|
-- Testing fsockopen() function with less than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: fsockopen() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Attempting to connect to a non-existent socket --
|
||||||
|
|
||||||
|
Warning: fsockopen(): unable to connect to tcp://127.0.0.1:31337 (%a) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(%d) "%a"
|
||||||
|
|
||||||
|
-- Attempting to connect using an invalid protocol --
|
||||||
|
|
||||||
|
Warning: fsockopen(): unable to connect to invalid://127.0.0.1:31337 (Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?"
|
||||||
|
Done
|
32
ext/standard/tests/network/fsockopen_variation1.phpt
Normal file
32
ext/standard/tests/network/fsockopen_variation1.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
testing fsockopen without a protocol string
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo "Open a server socket\n";
|
||||||
|
$server = stream_socket_server('tcp://127.0.0.1:31337');
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() without a protocol in the hostname string:\n";
|
||||||
|
$hostname = '127.0.0.1';
|
||||||
|
$port = '31337';
|
||||||
|
$client = fsockopen($hostname, $port);
|
||||||
|
var_dump($client);
|
||||||
|
fclose($client);
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() with address and port in same string, without a protocol:\n";
|
||||||
|
$address = $hostname . ':' . $port;
|
||||||
|
$second_client = fsockopen($address);
|
||||||
|
var_dump($second_client);
|
||||||
|
fclose($second_client);
|
||||||
|
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Open a server socket
|
||||||
|
|
||||||
|
Calling fsockopen() without a protocol in the hostname string:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
Calling fsockopen() with address and port in same string, without a protocol:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
Done
|
48
ext/standard/tests/network/fsockopen_variation2.phpt
Normal file
48
ext/standard/tests/network/fsockopen_variation2.phpt
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
--TEST--
|
||||||
|
testing fsockopen() with udp sockets
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$hostname = 'udp://127.0.0.1';
|
||||||
|
$port = '31337';
|
||||||
|
|
||||||
|
echo "Open a server socket\n";
|
||||||
|
$server = stream_socket_server($hostname . ':' . $port, $errno, $errstr, STREAM_SERVER_BIND);
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen():\n";
|
||||||
|
$client = fsockopen($hostname, $port);
|
||||||
|
var_dump($client);
|
||||||
|
|
||||||
|
echo "\nPass some data between the sockets:\n";
|
||||||
|
fwrite($client, "0123456789");
|
||||||
|
var_dump(fread($server, 10));
|
||||||
|
fclose($client);
|
||||||
|
|
||||||
|
echo "\nCalling fsockopen() with address and port in same string:\n";
|
||||||
|
$address = $hostname . ':' . $port;
|
||||||
|
$second_client = fsockopen($address);
|
||||||
|
var_dump($second_client);
|
||||||
|
|
||||||
|
echo "\nPass some data between the sockets:\n";
|
||||||
|
fwrite($second_client, "0123456789");
|
||||||
|
var_dump(fread($server, 10));
|
||||||
|
fclose($second_client);
|
||||||
|
|
||||||
|
echo "Done";
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Open a server socket
|
||||||
|
|
||||||
|
Calling fsockopen():
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
Pass some data between the sockets:
|
||||||
|
string(10) "0123456789"
|
||||||
|
|
||||||
|
Calling fsockopen() with address and port in same string:
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
Pass some data between the sockets:
|
||||||
|
string(10) "0123456789"
|
||||||
|
Done
|
37
ext/standard/tests/network/ip2long_error.phpt
Normal file
37
ext/standard/tests/network/ip2long_error.phpt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
--TEST--
|
||||||
|
Test ip2long() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : int ip2long(string ip_address)
|
||||||
|
* Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address
|
||||||
|
* Source code: ext/standard/basic_functions.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing ip2long() : error conditions ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing ip2long() function with Zero arguments --\n";
|
||||||
|
var_dump( ip2long() );
|
||||||
|
|
||||||
|
//Test ip2long with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing ip2long() function with more than expected no. of arguments --\n";
|
||||||
|
$ip_address = '127.0.0.1';
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( ip2long($ip_address, $extra_arg) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing ip2long() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing ip2long() function with Zero arguments --
|
||||||
|
|
||||||
|
Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing ip2long() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: ip2long() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
199
ext/standard/tests/network/ip2long_variation1.phpt
Normal file
199
ext/standard/tests/network/ip2long_variation1.phpt
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
--TEST--
|
||||||
|
Test ip2long() function : usage variation
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : int ip2long(string ip_address)
|
||||||
|
* Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address
|
||||||
|
* Source code: ext/standard/basic_functions.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing ip2long() : 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)
|
||||||
|
|
||||||
|
//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;
|
||||||
|
|
||||||
|
// add arrays
|
||||||
|
$index_array = array (1, 2, 3);
|
||||||
|
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||||
|
|
||||||
|
// resource
|
||||||
|
$res = fopen(__FILE__,'r');
|
||||||
|
|
||||||
|
//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
|
||||||
|
'resource' => $res,
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for ip_address
|
||||||
|
|
||||||
|
foreach($inputs as $key =>$value) {
|
||||||
|
echo "\n--$key--\n";
|
||||||
|
var_dump( ip2long($value) );
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($res);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing ip2long() : usage variation ***
|
||||||
|
|
||||||
|
--int 0--
|
||||||
|
int(0)
|
||||||
|
|
||||||
|
--int 1--
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
--int 12345--
|
||||||
|
int(12345)
|
||||||
|
|
||||||
|
--int -12345--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 10.5--
|
||||||
|
int(167772165)
|
||||||
|
|
||||||
|
--float -10.5--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float 12.3456789000e10--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float -12.3456789000e10--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--float .5--
|
||||||
|
int(5)
|
||||||
|
|
||||||
|
--empty array--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--int indexed array--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--associative array--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--nested arrays--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--uppercase NULL--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase null--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--lowercase true--
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
--lowercase false--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--uppercase TRUE--
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
--uppercase FALSE--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string DQ--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--empty string SQ--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithToString--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--instance of classWithoutToString--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--undefined var--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--unset var--
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--resource--
|
||||||
|
Error: 2 - ip2long() expects parameter 1 to be string, resource given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
37
ext/standard/tests/network/long2ip_error.phpt
Normal file
37
ext/standard/tests/network/long2ip_error.phpt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
--TEST--
|
||||||
|
Test long2ip() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string long2ip(int proper_address)
|
||||||
|
* Description: Converts an (IPv4) Internet network address into a string in Internet standard dotted format
|
||||||
|
* Source code: ext/standard/basic_functions.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing long2ip() : error conditions ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing long2ip() function with Zero arguments --\n";
|
||||||
|
var_dump( long2ip() );
|
||||||
|
|
||||||
|
//Test long2ip with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing long2ip() function with more than expected no. of arguments --\n";
|
||||||
|
$proper_address = 10;
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( long2ip($proper_address, $extra_arg) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing long2ip() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing long2ip() function with Zero arguments --
|
||||||
|
|
||||||
|
Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing long2ip() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: long2ip() expects exactly 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
196
ext/standard/tests/network/long2ip_variation1.phpt
Normal file
196
ext/standard/tests/network/long2ip_variation1.phpt
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
--TEST--
|
||||||
|
Test long2ip() function : usage variation
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) == "WIN")
|
||||||
|
die("skip don't run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string long2ip(int proper_address)
|
||||||
|
* Description: Converts an (IPv4) Internet network address into a string in Internet standard dotted format
|
||||||
|
* Source code: ext/standard/basic_functions.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing long2ip() : 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)
|
||||||
|
|
||||||
|
//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;
|
||||||
|
|
||||||
|
// add arrays
|
||||||
|
$index_array = array (1, 2, 3);
|
||||||
|
$assoc_array = array ('one' => 1, 'two' => 2);
|
||||||
|
|
||||||
|
// resource
|
||||||
|
$res = fopen(__FILE__,'r');
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// float data
|
||||||
|
'float 10.5' => 10.5,
|
||||||
|
'float -10.5' => -10.5,
|
||||||
|
'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
|
||||||
|
'resource' => $res,
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for proper_address
|
||||||
|
|
||||||
|
foreach($inputs as $key =>$value) {
|
||||||
|
echo "\n--$key--\n";
|
||||||
|
var_dump( long2ip($value) );
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($res);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing long2ip() : usage variation ***
|
||||||
|
|
||||||
|
--float 10.5--
|
||||||
|
string(8) "0.0.0.10"
|
||||||
|
|
||||||
|
--float -10.5--
|
||||||
|
string(15) "255.255.255.246"
|
||||||
|
|
||||||
|
--float .5--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--empty array--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--int indexed array--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--associative array--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--nested arrays--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--uppercase NULL--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--lowercase null--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--lowercase true--
|
||||||
|
string(7) "0.0.0.1"
|
||||||
|
|
||||||
|
--lowercase false--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--uppercase TRUE--
|
||||||
|
string(7) "0.0.0.1"
|
||||||
|
|
||||||
|
--uppercase FALSE--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--empty string DQ--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--empty string SQ--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--string DQ--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--string SQ--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--mixed case string--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--heredoc--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--instance of classWithToString--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--instance of classWithoutToString--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
--undefined var--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--unset var--
|
||||||
|
string(7) "0.0.0.0"
|
||||||
|
|
||||||
|
--resource--
|
||||||
|
Error: 2 - long2ip() expects parameter 1 to be string, resource given, %s(%d)
|
||||||
|
NULL
|
||||||
|
===DONE===
|
27
ext/standard/tests/network/socket_get_status_basic.phpt
Normal file
27
ext/standard/tests/network/socket_get_status_basic.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Testing socket_get_status()
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$tcp_socket = stream_socket_server('tcp://127.0.0.1:31337');
|
||||||
|
var_dump(socket_get_status($tcp_socket));
|
||||||
|
fclose($tcp_socket);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
array(7) {
|
||||||
|
["stream_type"]=>
|
||||||
|
string(10) "tcp_socket"
|
||||||
|
["mode"]=>
|
||||||
|
string(2) "r+"
|
||||||
|
["unread_bytes"]=>
|
||||||
|
int(0)
|
||||||
|
["seekable"]=>
|
||||||
|
bool(false)
|
||||||
|
["timed_out"]=>
|
||||||
|
bool(false)
|
||||||
|
["blocked"]=>
|
||||||
|
bool(true)
|
||||||
|
["eof"]=>
|
||||||
|
bool(false)
|
||||||
|
}
|
31
ext/standard/tests/network/syslog_basic-win32.phpt
Normal file
31
ext/standard/tests/network/syslog_basic-win32.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test syslog() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||||
|
die("skip Only run on Windows");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool syslog(int priority, string message)
|
||||||
|
* Description: Generate a system log message
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing syslog() : basic functionality ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Initialise all required variables
|
||||||
|
$priority = LOG_WARNING;
|
||||||
|
$message = 'A test syslog call invocation';
|
||||||
|
|
||||||
|
// Calling syslog() with all possible arguments
|
||||||
|
var_dump( syslog($priority, $message) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing syslog() : basic functionality ***
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
40
ext/standard/tests/network/syslog_error.phpt
Normal file
40
ext/standard/tests/network/syslog_error.phpt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
Test syslog() function : error conditions
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool syslog(int priority, string message)
|
||||||
|
* Description: Generate a system log message
|
||||||
|
* Source code: ext/standard/syslog.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing syslog() : error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
//Test syslog with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing syslog() function with more than expected no. of arguments --\n";
|
||||||
|
$priority = 10;
|
||||||
|
$message = 'string_val';
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( syslog($priority, $message, $extra_arg) );
|
||||||
|
|
||||||
|
// Testing syslog with one less than the expected number of arguments
|
||||||
|
echo "\n-- Testing syslog() function with less than expected no. of arguments --\n";
|
||||||
|
$priority = 10;
|
||||||
|
var_dump( syslog($priority) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing syslog() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing syslog() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: syslog() expects exactly 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing syslog() function with less than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: syslog() expects exactly 2 parameters, 1 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue