]> 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]

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..34e6cd6
--- /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 ***
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
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..39bdf80
--- /dev/null
@@ -0,0 +1,41 @@
+--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 ***
+string(1) "0"
+
+Catchable fatal error: Object of class classWithoutToString could not be converted to string in %s.php on line %d
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..22188c7
--- /dev/null
@@ -0,0 +1,20 @@
+--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 deprecated in PHP 5.3 and greater in %s on line 0
+*** Test by calling method or function with deprecated option ***
+string(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..27c2e7e
--- /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 ***
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
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..cf72600
--- /dev/null
@@ -0,0 +1,37 @@
+--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)
+
+Catchable fatal error: Object of class classWithoutToString could not be converted to string in %s.php on line %d
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..0a0ed59
--- /dev/null
@@ -0,0 +1,37 @@
+--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)
+
+Catchable fatal error: Object of class classWithoutToString could not be converted to string in %s.php on line %d
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..da936ed
--- /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 ***
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)
+
+Notice: Array to string conversion in %s.php on line %d
+bool(false)