summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandy wharmby <wharmby@php.net>2009-02-01 18:55:26 +0000
committerandy wharmby <wharmby@php.net>2009-02-01 18:55:26 +0000
commit7c07a980ed7af19919e8ecc3b94751f714c9e219 (patch)
tree5a2e8e071350b2ccd3f2fe2717aea9e3d4e2255a
parent1cdf8160cec62c4da2bc9f3e6c03a26c579e0102 (diff)
downloadphp-git-7c07a980ed7af19919e8ecc3b94751f714c9e219.tar.gz
New get_defined_vars(), get_included_files(), get_magic_quotes() and getmypid() tests. Tested on Winows, Linux and Linux 64
-rw-r--r--ext/standard/tests/general_functions/get_defined_vars_basic.phpt152
-rw-r--r--ext/standard/tests/general_functions/get_include_path_basic.phpt37
-rw-r--r--ext/standard/tests/general_functions/get_included_files.phpt63
-rw-r--r--ext/standard/tests/general_functions/get_included_files_inc1.inc3
-rw-r--r--ext/standard/tests/general_functions/get_included_files_inc2.inc4
-rw-r--r--ext/standard/tests/general_functions/get_included_files_inc3.inc4
-rw-r--r--ext/standard/tests/general_functions/get_magic_quotes_gpc.phpt49
-rw-r--r--ext/standard/tests/general_functions/get_magic_quotes_runtime.phpt65
-rw-r--r--ext/standard/tests/general_functions/getmypid_basic.phpt20
9 files changed, 397 insertions, 0 deletions
diff --git a/ext/standard/tests/general_functions/get_defined_vars_basic.phpt b/ext/standard/tests/general_functions/get_defined_vars_basic.phpt
new file mode 100644
index 0000000000..3aa6e72a92
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_defined_vars_basic.phpt
@@ -0,0 +1,152 @@
+--TEST--
+Test get_defined_vars() function
+--FILE--
+<?php
+/* Prototype: array get_defined_vars ( void )
+ Description: This function returns a multidimensional array containing a list of all defined
+ variables, be them environment, server or user-defined variables, within the scope that
+ get_defined_vars() is called.
+*/
+
+echo "Simple testcase for get_defined_vars() function\n\n";
+
+function f1() {
+ echo "\n-- Function f1() called --\n";
+ $vars = get_defined_vars();
+
+ if (count($vars) != 0) {
+ echo "TEST FAILED\n";
+ }
+
+ echo "\n-- ..define some local variables --\n";
+ $i = 123;
+ $f = 123.456;
+ $b = false;
+ $s = "Hello World";
+ $arr = array(1,2,3,4);
+ var_dump( get_defined_vars() );
+ f2();
+}
+
+function f2() {
+ echo "\n -- Function f2() called --\n";
+ $vars= get_defined_vars();
+
+ if (count($vars) != 0) {
+ echo "TEST FAILED\n";
+ }
+
+ echo "\n-- ...define some variables --\n";
+ $i = 456;
+ $f = 456.678;
+ $b = true;
+ $s = "Goodnight";
+ $arr = array("foo", "bar");
+ var_dump( get_defined_vars() );
+
+ echo "\n-- ...define some more variables --\n";
+ $i1 = 456;
+ $f1 = 456.678;
+ $b1 = true;
+ var_dump( get_defined_vars() );
+
+}
+
+echo "\n-- Get variables at global scope --\n";
+$vars = get_defined_vars();
+
+if (count($vars) == 0) {
+ echo "TEST FAILED - Global variables missing at global scope\n";
+}
+
+// call a function
+f1();
+
+?>
+===DONE===
+--EXPECT--
+Simple testcase for get_defined_vars() function
+
+
+-- Get variables at global scope --
+
+-- Function f1() called --
+
+-- ..define some local variables --
+array(6) {
+ ["vars"]=>
+ array(0) {
+ }
+ ["i"]=>
+ int(123)
+ ["f"]=>
+ float(123.456)
+ ["b"]=>
+ bool(false)
+ ["s"]=>
+ string(11) "Hello World"
+ ["arr"]=>
+ array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ }
+}
+
+ -- Function f2() called --
+
+-- ...define some variables --
+array(6) {
+ ["vars"]=>
+ array(0) {
+ }
+ ["i"]=>
+ int(456)
+ ["f"]=>
+ float(456.678)
+ ["b"]=>
+ bool(true)
+ ["s"]=>
+ string(9) "Goodnight"
+ ["arr"]=>
+ array(2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "bar"
+ }
+}
+
+-- ...define some more variables --
+array(9) {
+ ["vars"]=>
+ array(0) {
+ }
+ ["i"]=>
+ int(456)
+ ["f"]=>
+ float(456.678)
+ ["b"]=>
+ bool(true)
+ ["s"]=>
+ string(9) "Goodnight"
+ ["arr"]=>
+ array(2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "bar"
+ }
+ ["i1"]=>
+ int(456)
+ ["f1"]=>
+ float(456.678)
+ ["b1"]=>
+ bool(true)
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/general_functions/get_include_path_basic.phpt b/ext/standard/tests/general_functions/get_include_path_basic.phpt
new file mode 100644
index 0000000000..999862bc64
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_include_path_basic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test get_include_path() function
+--INI--
+include_path=.
+--FILE--
+<?php
+/* Prototype: string get_include_path ( void )
+ * Description: Gets the current include_path configuration option
+
+*/
+
+echo "*** Testing get_include_path()\n";
+
+var_dump(get_include_path());
+
+if (ini_get("include_path") == get_include_path()) {
+ echo "PASSED\n";
+} else {
+ echo "FAILED\n";
+}
+
+echo "\nError cases:\n";
+var_dump(get_include_path(TRUE));
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_include_path()
+string(1) "."
+PASSED
+
+Error cases:
+
+Warning: get_include_path() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/general_functions/get_included_files.phpt b/ext/standard/tests/general_functions/get_included_files.phpt
new file mode 100644
index 0000000000..e7e1ed5219
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_included_files.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test get_include_files() function
+--INI--
+include_path=.
+--FILE--
+<?php
+/* Prototype: array get_included_files ( void )
+ * Description: Returns an array with the names of included or required files
+
+*/
+
+echo "*** Testing get_included_files()\n";
+
+echo "\n-- List included files at start --\n";
+var_dump(get_included_files());
+
+include(dirname(__FILE__)."/get_included_files_inc1.inc");
+echo "\n-- List included files atfter including inc1 -\n";
+var_dump(get_included_files());
+
+include(dirname(__FILE__)."/get_included_files_inc2.inc");
+echo "\n-- List included files atfter including inc2 which will include inc3 which includes inc1 --\n";
+var_dump(get_included_files());
+
+echo "\n-- Error cases --\n";
+var_dump(get_included_files(true));
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_included_files()
+
+-- List included files at start --
+array(1) {
+ [0]=>
+ string(%d) "%sget_included_files.php"
+}
+
+-- List included files atfter including inc1 -
+array(2) {
+ [0]=>
+ string(%d) "%sget_included_files.php"
+ [1]=>
+ string(%d) "%sget_included_files_inc1.inc"
+}
+
+-- List included files atfter including inc2 which will include inc3 which includes inc1 --
+array(4) {
+ [0]=>
+ string(%d) "%sget_included_files.php"
+ [1]=>
+ string(%d) "%sget_included_files_inc1.inc"
+ [2]=>
+ string(%d) "%sget_included_files_inc2.inc"
+ [3]=>
+ string(%d) "%sget_included_files_inc3.inc"
+}
+
+-- Error cases --
+
+Warning: get_included_files() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/general_functions/get_included_files_inc1.inc b/ext/standard/tests/general_functions/get_included_files_inc1.inc
new file mode 100644
index 0000000000..344e300e08
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_included_files_inc1.inc
@@ -0,0 +1,3 @@
+<?php
+/* dummy include*/
+?>
diff --git a/ext/standard/tests/general_functions/get_included_files_inc2.inc b/ext/standard/tests/general_functions/get_included_files_inc2.inc
new file mode 100644
index 0000000000..318eba00c5
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_included_files_inc2.inc
@@ -0,0 +1,4 @@
+<?php
+/* dummy include*/
+include(dirname(__FILE__)."/get_included_files_inc3.inc");
+?>
diff --git a/ext/standard/tests/general_functions/get_included_files_inc3.inc b/ext/standard/tests/general_functions/get_included_files_inc3.inc
new file mode 100644
index 0000000000..f666edf2b9
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_included_files_inc3.inc
@@ -0,0 +1,4 @@
+<?php
+/* dummy include*/
+include(dirname(__FILE__)."/get_included_files_inc1.inc");
+?>
diff --git a/ext/standard/tests/general_functions/get_magic_quotes_gpc.phpt b/ext/standard/tests/general_functions/get_magic_quotes_gpc.phpt
new file mode 100644
index 0000000000..cfa4dcc681
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_magic_quotes_gpc.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test get_magic_quotes_gpc() function
+--INI--
+magic_quotes_gpc = 0
+--FILE--
+<?php
+/* Prototype: int get_magic_quotes_gpc ( void )
+ * Description: Gets the current configuration setting of magic quotes gpc
+*/
+
+echo "Simple testcase for get_magic_quotes_gpc() function\n";
+
+$g = get_magic_quotes_gpc();
+echo "\n-- magic quotes gpc set in INI file: " . $g . " --\n";
+
+echo "\n-- Set magic quotes gpc to 1 - not allowed so should fail! --\n";
+var_dump(ini_set("magic_quotes_gpc", 1));
+$g = get_magic_quotes_gpc();
+echo "\n-- magic quotes gpc after set: " . $g . " --\n";
+
+echo "\n-- Set magic quotes gpc to 0: --\n";
+var_dump(ini_set("magic_quotes_gpc", 0));
+$g = get_magic_quotes_gpc();
+echo "\n-- magic quotes gpc after set: " . $g . " --\n";
+
+echo "\n-- Error cases --\n";
+// no checks on number of args
+var_dump(get_magic_quotes_gpc(true));
+
+?>
+===DONE===
+--EXPECT--
+Simple testcase for get_magic_quotes_gpc() function
+
+-- magic quotes gpc set in INI file: 0 --
+
+-- Set magic quotes gpc to 1 - not allowed so should fail! --
+bool(false)
+
+-- magic quotes gpc after set: 0 --
+
+-- Set magic quotes gpc to 0: --
+bool(false)
+
+-- magic quotes gpc after set: 0 --
+
+-- Error cases --
+int(0)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/general_functions/get_magic_quotes_runtime.phpt b/ext/standard/tests/general_functions/get_magic_quotes_runtime.phpt
new file mode 100644
index 0000000000..761accce34
--- /dev/null
+++ b/ext/standard/tests/general_functions/get_magic_quotes_runtime.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test get_magic_quotes_runtime() function
+--INI-
+magic_quotes_runtime = 0
+--FILE--
+<?php
+/* Prototype: int get_magic_quotes_runtime ( void )
+ * Description: Gets the current active configuration setting of magic_quotes_runtime
+*/
+
+echo "Simple testcase for get_magic_quotes_runtime() function\n";
+
+$g = get_magic_quotes_runtime();
+echo "\n-- magic quotes runtime set in INI file: " . $g . " --\n";
+
+echo "\n-- Set magic quotes runtime to 1: --\n";
+var_dump(set_magic_quotes_runtime(1));
+$g = get_magic_quotes_runtime();
+echo "\n-- magic quotes runtime after set: " . $g . " --\n";
+
+echo "\n-- Set magic quotes runtime to 0: --\n";
+var_dump(set_magic_quotes_runtime(0));
+$g = get_magic_quotes_runtime();
+echo "\n-- magic quotes runtime after set: " . $g . " --\n";
+
+echo "\n-- Set magic quotes runtime to 1: --\n";
+var_dump(set_magic_quotes_runtime(1));
+$g = get_magic_quotes_runtime();
+echo "\n-- magic quotes runtime after set: " . $g . " --\n";
+
+echo "\n-- Error cases --\n";
+// no checks on number of args
+var_dump(get_magic_quotes_runtime(true));
+
+?>
+===DONE===
+--EXPECTF--
+Simple testcase for get_magic_quotes_runtime() function
+
+-- magic quotes runtime set in INI file: 0 --
+
+-- Set magic quotes runtime to 1: --
+
+Deprecated: Function set_magic_quotes_runtime() is deprecated in %s on line %d
+bool(true)
+
+-- magic quotes runtime after set: 1 --
+
+-- Set magic quotes runtime to 0: --
+
+Deprecated: Function set_magic_quotes_runtime() is deprecated in %s on line %d
+bool(true)
+
+-- magic quotes runtime after set: 0 --
+
+-- Set magic quotes runtime to 1: --
+
+Deprecated: Function set_magic_quotes_runtime() is deprecated in %s on line %d
+bool(true)
+
+-- magic quotes runtime after set: 1 --
+
+-- Error cases --
+int(1)
+===DONE===
diff --git a/ext/standard/tests/general_functions/getmypid_basic.phpt b/ext/standard/tests/general_functions/getmypid_basic.phpt
new file mode 100644
index 0000000000..869eb59442
--- /dev/null
+++ b/ext/standard/tests/general_functions/getmypid_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test getmypid() function: basic test
+--FILE--
+<?php
+/* Prototype : int getmypid ( void )
+ * Description: Gets the current PHP process ID.
+ * Source code: ext/standard/pageinfo.c
+ * Alias to functions:
+ */
+
+echo "Simple testcase for getmypid() function\n";
+
+var_dump(getmypid());
+
+echo "Done\n";
+?>
+--EXPECTF--
+Simple testcase for getmypid() function
+int(%d)
+Done \ No newline at end of file