]> granicus.if.org Git - php/commitdiff
More tests from 2009 testfest
authorZoe Slattery <zoe@php.net>
Sun, 30 Aug 2009 12:19:50 +0000 (12:19 +0000)
committerZoe Slattery <zoe@php.net>
Sun, 30 Aug 2009 12:19:50 +0000 (12:19 +0000)
ext/standard/tests/general_functions/get_cfg_var_variation1.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_cfg_var_variation6.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_cfg_var_variation8.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/getservbyname_variation1.phpt [new file with mode: 0755]
ext/standard/tests/general_functions/getservbyname_variation13.phpt [new file with mode: 0755]
ext/standard/tests/general_functions/getservbyname_variation6.phpt [new file with mode: 0755]
ext/standard/tests/general_functions/getservbyname_variation8.phpt [new file with mode: 0755]
ext/standard/tests/general_functions/getservbyport_variation1.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation1.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation1.phpt
new file mode 100644 (file)
index 0000000..b96821d
--- /dev/null
@@ -0,0 +1,46 @@
+--TEST--
+Test function get_cfg_var() by substituting argument 1 with array values.
+--CREDITS--
+Francesco Fullone ff@ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--INI--
+session.use_cookies=0
+session.serialize_handler=php
+session.save_handler=files
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 1 with array values ***\n";
+
+
+
+$index_array = array(1, 2, 3);
+$assoc_array = array(1 => 'one', 2 => 'two');
+
+$variation_array = array(
+  'empty array' => array(),
+  'int indexed array' => $index_array,
+  'associative array' => $assoc_array,
+  'nested arrays' => array('foo', $index_array, $assoc_array),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(get_cfg_var( $var  ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 1 with array values ***
+
+Warning: get_cfg_var() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: get_cfg_var() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: get_cfg_var() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: get_cfg_var() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation6.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation6.phpt
new file mode 100644 (file)
index 0000000..2c4aa56
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Test function get_cfg_var() by substituting argument 1 with object values.
+--CREDITS--
+Francesco Fullone ff@ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--INI--
+session.use_cookies=0
+session.serialize_handler=php
+session.save_handler=files
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 1 with object values ***\n";
+
+
+
+class classWithToString
+{
+        public function __toString() {
+                return "session.use_cookies";
+        }
+}
+
+class classWithoutToString
+{
+}
+
+$variation_array = array(
+  'instance of classWithToString' => new classWithToString(),
+  'instance of classWithoutToString' => new classWithoutToString(),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(get_cfg_var( $var  ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 1 with object values ***
+unicode(1) "0"
+
+Warning: get_cfg_var() expects parameter 1 to be binary string, object given in %s.php on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
new file mode 100644 (file)
index 0000000..530bac4
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Test function get_cfg_var() by calling deprecated option
+--CREDITS--
+Francesco Fullone ff@ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--INI--
+register_globals=1
+--SKIPIF--
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or greater"); ?>
+--FILE--
+<?php
+echo "*** Test by calling method or function with deprecated option ***\n";
+var_dump(get_cfg_var( 'register_globals' ) );
+
+?>
+--EXPECTF--
+PHP Warning:  Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0
+*** Test by calling method or function with deprecated option ***
+unicode(1) "1"
diff --git a/ext/standard/tests/general_functions/getservbyname_variation1.phpt b/ext/standard/tests/general_functions/getservbyname_variation1.phpt
new file mode 100755 (executable)
index 0000000..ec01cc4
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test function getservbyname() by substituting argument 1 with array values.
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 1 with array values ***\n";
+
+$protocol = "tcp";
+
+
+$index_array = array(1, 2, 3);
+$assoc_array = array(1 => 'one', 2 => 'two');
+
+$variation_array = array(
+  'empty array' => array(),
+  'int indexed array' => $index_array,
+  'associative array' => $assoc_array,
+  'nested arrays' => array('foo', $index_array, $assoc_array),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(getservbyname( $var ,  $protocol ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 1 with array values ***
+
+Warning: getservbyname() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 1 to be binary string, array given in %s on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/getservbyname_variation13.phpt b/ext/standard/tests/general_functions/getservbyname_variation13.phpt
new file mode 100755 (executable)
index 0000000..96c9a07
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test function getservbyname() by substituting argument 2 with object values.
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 2 with object values ***\n";
+
+$service = "www";
+
+
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+class classWithoutToString
+{
+}
+
+$variation_array = array(
+  'instance of classWithToString' => new classWithToString(),
+  'instance of classWithoutToString' => new classWithoutToString(),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(getservbyname( $service, $var  ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 2 with object values ***
+bool(false)
+
+Warning: getservbyname() expects parameter 2 to be binary string, object given in %s.php on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/getservbyname_variation6.phpt b/ext/standard/tests/general_functions/getservbyname_variation6.phpt
new file mode 100755 (executable)
index 0000000..a2f57c8
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test function getservbyname() by substituting argument 1 with object values.
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 1 with object values ***\n";
+
+$protocol = "tcp";
+
+
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+class classWithoutToString
+{
+}
+
+$variation_array = array(
+  'instance of classWithToString' => new classWithToString(),
+  'instance of classWithoutToString' => new classWithoutToString(),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(getservbyname( $var ,  $protocol ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 1 with object values ***
+bool(false)
+
+Warning: getservbyname() expects parameter 1 to be binary string, object given in %s.php on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/getservbyname_variation8.phpt b/ext/standard/tests/general_functions/getservbyname_variation8.phpt
new file mode 100755 (executable)
index 0000000..d121bed
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test function getservbyname() by substituting argument 2 with array values.
+--FILE--
+<?php
+
+
+echo "*** Test substituting argument 2 with array values ***\n";
+
+$service = "www";
+
+
+$index_array = array(1, 2, 3);
+$assoc_array = array(1 => 'one', 2 => 'two');
+
+$variation_array = array(
+  'empty array' => array(),
+  'int indexed array' => $index_array,
+  'associative array' => $assoc_array,
+  'nested arrays' => array('foo', $index_array, $assoc_array),
+  );
+
+
+foreach ( $variation_array as $var ) {
+  var_dump(getservbyname( $service, $var  ) );
+}
+?>
+--EXPECTF--
+*** Test substituting argument 2 with array values ***
+
+Warning: getservbyname() expects parameter 2 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 2 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 2 to be binary string, array given in %s on line %d
+NULL
+
+Warning: getservbyname() expects parameter 2 to be binary string, array given in %s on line %d
+NULL
diff --git a/ext/standard/tests/general_functions/getservbyport_variation1.phpt b/ext/standard/tests/general_functions/getservbyport_variation1.phpt
new file mode 100644 (file)
index 0000000..e5d4899
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test function getservbyport() by calling it more than or less than its expected arguments
+--DESCRIPTION--
+Test function passing invalid port number and invalid protocol name
+--CREDITS--
+Italian PHP TestFest 2009 Cesena 19-20-21 june
+Fabio Fabbrucci (fabbrucci@grupporetina.com)
+Michele Orselli (mo@ideato.it)
+Simone Gentili (sensorario@gmail.com)
+--FILE--
+<?php
+       var_dump(getservbyport( -1, "tcp" ));
+       var_dump(getservbyport( 80, "ppp" ));
+       var_dump(getservbyport( null, null));
+       var_dump(getservbyport( array(), array()));
+       var_dump(getservbyport( array(80), array("tcp")));
+       var_dump(getservbyport( array(2, 3), array("one"=>1, "two"=>2)));
+       var_dump(getservbyport( 2, 2));
+       var_dump(getservbyport( "80", "tcp"));
+       var_dump(getservbyport( new stdClass(), new stdClass()));
+       
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+
+Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d
+NULL
+bool(false)
+unicode(%d) "%s"
+
+Warning: getservbyport() expects parameter 1 to be long, object given in %s on line %d
+NULL