]> granicus.if.org Git - php/commitdiff
New get_defined_vars(), get_included_files(), get_magic_quotes() and getmypid() tests...
authorandy wharmby <wharmby@php.net>
Sun, 1 Feb 2009 18:55:24 +0000 (18:55 +0000)
committerandy wharmby <wharmby@php.net>
Sun, 1 Feb 2009 18:55:24 +0000 (18:55 +0000)
ext/standard/tests/general_functions/get_defined_vars_basic.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_include_path_basic.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_included_files.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_included_files_inc1.inc [new file with mode: 0644]
ext/standard/tests/general_functions/get_included_files_inc2.inc [new file with mode: 0644]
ext/standard/tests/general_functions/get_included_files_inc3.inc [new file with mode: 0644]
ext/standard/tests/general_functions/get_magic_quotes_gpc.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/get_magic_quotes_runtime.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/getmypid_basic.phpt [new file with mode: 0644]

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 (file)
index 0000000..586e660
--- /dev/null
@@ -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) {
+  [u"vars"]=>
+  array(0) {
+  }
+  [u"i"]=>
+  int(123)
+  [u"f"]=>
+  float(123.456)
+  [u"b"]=>
+  bool(false)
+  [u"s"]=>
+  unicode(11) "Hello World"
+  [u"arr"]=>
+  array(4) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+    [3]=>
+    int(4)
+  }
+}
+
+ -- Function f2() called --
+
+-- ...define some variables --
+array(6) {
+  [u"vars"]=>
+  array(0) {
+  }
+  [u"i"]=>
+  int(456)
+  [u"f"]=>
+  float(456.678)
+  [u"b"]=>
+  bool(true)
+  [u"s"]=>
+  unicode(9) "Goodnight"
+  [u"arr"]=>
+  array(2) {
+    [0]=>
+    unicode(3) "foo"
+    [1]=>
+    unicode(3) "bar"
+  }
+}
+
+-- ...define some more variables --
+array(9) {
+  [u"vars"]=>
+  array(0) {
+  }
+  [u"i"]=>
+  int(456)
+  [u"f"]=>
+  float(456.678)
+  [u"b"]=>
+  bool(true)
+  [u"s"]=>
+  unicode(9) "Goodnight"
+  [u"arr"]=>
+  array(2) {
+    [0]=>
+    unicode(3) "foo"
+    [1]=>
+    unicode(3) "bar"
+  }
+  [u"i1"]=>
+  int(456)
+  [u"f1"]=>
+  float(456.678)
+  [u"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 (file)
index 0000000..d29ed0f
--- /dev/null
@@ -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()
+unicode(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 (file)
index 0000000..8b82e94
--- /dev/null
@@ -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]=>
+  unicode(%d) "%sget_included_files.php"
+}
+
+-- List included files atfter including inc1 -
+array(2) {
+  [0]=>
+  unicode(%d) "%sget_included_files.php"
+  [1]=>
+  unicode(%d) "%sget_included_files_inc1.inc"
+}
+
+-- List included files atfter including inc2 which will include inc3 which includes inc1 --
+array(4) {
+  [0]=>
+  unicode(%d) "%sget_included_files.php"
+  [1]=>
+  unicode(%d) "%sget_included_files_inc1.inc"
+  [2]=>
+  unicode(%d) "%sget_included_files_inc2.inc"
+  [3]=>
+  unicode(%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 (file)
index 0000000..344e300
--- /dev/null
@@ -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 (file)
index 0000000..318eba0
--- /dev/null
@@ -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 (file)
index 0000000..f666edf
--- /dev/null
@@ -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 (file)
index 0000000..d06cd95
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Test get_magic_quotes_gpc() function
+--FILE--
+<?php
+/* Prototype: int get_magic_quotes_gpc  ( void  )
+ * Description: Gets the current configuration setting of magic quotes gpc
+ * 
+ * On PHP 6 this function always returns FALSE
+*/
+
+echo "Simple testcase for get_magic_quotes_gpc() function\n";
+
+var_dump(get_magic_quotes_gpc()); 
+
+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
+bool(false)
+
+-- Error cases --
+bool(false)
+===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 (file)
index 0000000..033e2c0
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Test get_magic_quotes_runtime() function
+--FILE--
+<?php
+/* Prototype: int get_magic_quotes_runtime  ( void  )
+ * Description: Gets the current active configuration setting of magic_quotes_runtime
+ *
+ * On PHP 6 this function always returns FALSE
+*/
+
+echo "Simple testcase for get_magic_quotes_runtime() function\n";
+
+var_dump(get_magic_quotes_runtime());
+
+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
+bool(false)
+
+-- Error cases --
+bool(false)
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/general_functions/getmypid_basic.phpt b/ext/standard/tests/general_functions/getmypid_basic.phpt
new file mode 100644 (file)
index 0000000..869eb59
--- /dev/null
@@ -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