wharmby                                  Mon, 03 Aug 2009 23:12:43 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=286771

Log:
New basic tests for get_defined_constants(), get_loaded_extensions() and 
get_resource_type() functions. Tested on Windows, Linux and Linux 64 bit

Changed paths:
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_error.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_basic.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_error.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_variation1.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_error.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_basic.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_error.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_variation1.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_error.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_basic.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_error.phpt
    A   
php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_variation1.phpt

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,39 @@
+--TEST--
+Test get_defined_constants() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : basic functionality ***\n";
+
+var_dump(gettype(get_defined_constants(true)));
+var_dump(gettype(get_defined_constants()));
+
+$arr1 = get_defined_constants(false);
+$arr2 = get_defined_constants();
+var_dump(array_diff($arr1, $arr2));
+
+$n1 = count(get_defined_constants());
+define("USER_CONSTANT", "test");
+$arr2 = get_defined_constants();
+$n2 = count($arr2);
+
+if ($n2 == $n1 + 1 && array_key_exists("USER_CONSTANT", $arr2)) {
+	echo "TEST PASSED\n";
+} else {
+	echo "TEST FAILED\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : basic functionality ***
+string(5) "array"
+string(5) "array"
+array(0) {
+}
+TEST PASSED
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_defined_constants_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,25 @@
+--TEST--
+Test get_defined_constants() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : error conditions ***\n";
+
+echo "\n-- Testing get_defined_constants() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( get_defined_constants(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : error conditions ***
+
+-- Testing get_defined_constants() function with more than expected no. of arguments --
+
+Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line 11
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,23 @@
+--TEST--
+Test get_loaded_extensions() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : basic functionality ***\n";
+
+echo "Get loaded extensions\n";
+var_dump(get_loaded_extensions());
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : basic functionality ***
+Get loaded extensions
+array(%d) {
+%a
+}
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,26 @@
+--TEST--
+Test get_loaded_extensions() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : error conditions ***\n";
+
+echo "\n-- Testing get_loaded_extensions() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_loaded_extensions(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : error conditions ***
+
+-- Testing get_loaded_extensions() function with more than expected no. of arguments --
+
+Warning: get_loaded_extensions() expects at most 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,20 @@
+--TEST--
+Test get_resource_type() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : basic functionality ***\n";
+
+$res = fopen(__FILE__, "r");
+var_dump(get_resource_type($res));
+
+?>
+===DONE===
+--EXPECT--
+*** Testing get_resource_type() : basic functionality ***
+string(6) "stream"
+===DONE===

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,34 @@
+--TEST--
+Test get_resource_type() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : error conditions ***\n";
+
+echo "\n-- Testing get_resource_type() function with Zero arguments --\n";
+var_dump( get_resource_type() );
+
+echo "\n-- Testing get_resource_type() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_resource_type($res, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : error conditions ***
+
+-- Testing get_resource_type() function with Zero arguments --
+
+Warning: Wrong parameter count for get_resource_type() in %s on line %d
+NULL
+
+-- Testing get_resource_type() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for get_resource_type() in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_variation1.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,74 @@
+--TEST--
+Test get_resource_type() function : usage variations - different data types as handle arg
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : variation test ***\n";
+
+class Hello {
+  public function SayHello($arg) {
+  	echo "Hello\n";
+  }
+}
+
+$res = fopen(__FILE__, "r");
+
+$vars = array(
+	"bool"=>false,
+	"int 10"=>10,
+	"float 10.5"=>10.5,
+	"string"=>"Hello World",
+	"array"=>array(1,2,3,4,5),
+	"NULL"=>NULL,
+	"Object"=>new Hello()
+);
+
+foreach($vars as $variation =>$object) {
+      echo "\n-- $variation --\n";
+      var_dump(get_resource_type($object));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : variation test ***
+
+-- bool --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- int 10 --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- float 10.5 --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- string --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- array --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- NULL --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+
+-- Object --
+
+Warning: Supplied argument is not a valid resource handle in %s on line %d
+bool(false)
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,39 @@
+--TEST--
+Test get_defined_constants() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : basic functionality ***\n";
+
+var_dump(gettype(get_defined_constants(true)));
+var_dump(gettype(get_defined_constants()));
+
+$arr1 = get_defined_constants(false);
+$arr2 = get_defined_constants();
+var_dump(array_diff($arr1, $arr2));
+
+$n1 = count(get_defined_constants());
+define("USER_CONSTANT", "test");
+$arr2 = get_defined_constants();
+$n2 = count($arr2);
+
+if ($n2 == $n1 + 1 && array_key_exists("USER_CONSTANT", $arr2)) {
+	echo "TEST PASSED\n";
+} else {
+	echo "TEST FAILED\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : basic functionality ***
+string(5) "array"
+string(5) "array"
+array(0) {
+}
+TEST PASSED
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_defined_constants_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,25 @@
+--TEST--
+Test get_defined_constants() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : error conditions ***\n";
+
+echo "\n-- Testing get_defined_constants() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( get_defined_constants(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : error conditions ***
+
+-- Testing get_defined_constants() function with more than expected no. of arguments --
+
+Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line 11
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,23 @@
+--TEST--
+Test get_loaded_extensions() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : basic functionality ***\n";
+
+echo "Get loaded extensions\n";
+var_dump(get_loaded_extensions());
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : basic functionality ***
+Get loaded extensions
+array(%d) {
+%a
+}
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,26 @@
+--TEST--
+Test get_loaded_extensions() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : error conditions ***\n";
+
+echo "\n-- Testing get_loaded_extensions() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_resource_type(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : error conditions ***
+
+-- Testing get_loaded_extensions() function with more than expected no. of arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,20 @@
+--TEST--
+Test get_resource_type() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : basic functionality ***\n";
+
+$res = fopen(__FILE__, "r");
+var_dump(get_resource_type($res));
+
+?>
+===DONE===
+--EXPECT--
+*** Testing get_resource_type() : basic functionality ***
+string(6) "stream"
+===DONE===

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,34 @@
+--TEST--
+Test get_resource_type() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : error conditions ***\n";
+
+echo "\n-- Testing get_resource_type() function with Zero arguments --\n";
+var_dump( get_resource_type() );
+
+echo "\n-- Testing get_resource_type() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_resource_type($res, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : error conditions ***
+
+-- Testing get_resource_type() function with Zero arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing get_resource_type() function with more than expected no. of arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_variation1.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,74 @@
+--TEST--
+Test get_resource_type() function : usage variations - different data types as handle arg
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : variation test ***\n";
+
+class Hello {
+  public function SayHello($arg) {
+  	echo "Hello\n";
+  }
+}
+
+$res = fopen(__FILE__, "r");
+
+$vars = array(
+	"bool"=>true,
+	"int 10"=>10,
+	"float 10.5"=>10.5,
+	"string"=>"Hello World",
+	"array"=>array(1,2,3,4,5),
+	"NULL"=>NULL,
+	"Object"=>new Hello()
+);
+
+foreach($vars as $variation =>$object) {
+      echo "\n-- $variation --\n";
+      var_dump(get_resource_type($object));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : variation test ***
+
+-- bool --
+
+Warning: get_resource_type() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- int 10 --
+
+Warning: get_resource_type() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- float 10.5 --
+
+Warning: get_resource_type() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- string --
+
+Warning: get_resource_type() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+-- array --
+
+Warning: get_resource_type() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- NULL --
+
+Warning: get_resource_type() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- Object --
+
+Warning: get_resource_type() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_basic.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,39 @@
+--TEST--
+Test get_defined_constants() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : basic functionality ***\n";
+
+var_dump(gettype(get_defined_constants(true)));
+var_dump(gettype(get_defined_constants()));
+
+$arr1 = get_defined_constants(false);
+$arr2 = get_defined_constants();
+var_dump(array_diff($arr1, $arr2));
+
+$n1 = count(get_defined_constants());
+define("USER_CONSTANT", "test");
+$arr2 = get_defined_constants();
+$n2 = count($arr2);
+
+if ($n2 == $n1 + 1 && array_key_exists("USER_CONSTANT", $arr2)) {
+	echo "TEST PASSED\n";
+} else {
+	echo "TEST FAILED\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : basic functionality ***
+unicode(5) "array"
+unicode(5) "array"
+array(0) {
+}
+TEST PASSED
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_error.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_error.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_defined_constants_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,25 @@
+--TEST--
+Test get_defined_constants() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_defined_constants  ([ bool $categorize  ] )
+ * Description:  Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : error conditions ***\n";
+
+echo "\n-- Testing get_defined_constants() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( get_defined_constants(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : error conditions ***
+
+-- Testing get_defined_constants() function with more than expected no. of arguments --
+
+Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line 11
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,23 @@
+--TEST--
+Test get_loaded_extensions() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : basic functionality ***\n";
+
+echo "Get loaded extensions\n";
+var_dump(get_loaded_extensions());
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : basic functionality ***
+Get loaded extensions
+array(%d) {
+%a
+}
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,26 @@
+--TEST--
+Test get_loaded_extensions() function : error conditions
+--FILE--
+<?php
+/* Prototype  : array get_loaded_extensions  ([ bool $zend_extensions= false  ] )
+ * Description:  Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : error conditions ***\n";
+
+echo "\n-- Testing get_loaded_extensions() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_resource_type(true, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : error conditions ***
+
+-- Testing get_loaded_extensions() function with more than expected no. of arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_basic.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_basic.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_basic.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,20 @@
+--TEST--
+Test get_resource_type() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : basic functionality ***\n";
+
+$res = fopen(__FILE__, "r");
+var_dump(get_resource_type($res));
+
+?>
+===DONE===
+--EXPECT--
+*** Testing get_resource_type() : basic functionality ***
+unicode(6) "stream"
+===DONE===

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_error.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_error.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_error.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,34 @@
+--TEST--
+Test get_resource_type() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : error conditions ***\n";
+
+echo "\n-- Testing get_resource_type() function with Zero arguments --\n";
+var_dump( get_resource_type() );
+
+echo "\n-- Testing get_resource_type() function with more than expected no. of arguments --\n";
+$res = fopen(__FILE__, "r");
+$extra_arg = 10;
+var_dump( get_resource_type($res, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : error conditions ***
+
+-- Testing get_resource_type() function with Zero arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing get_resource_type() function with more than expected no. of arguments --
+
+Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_variation1.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/get_resource_type_variation1.phpt	2009-08-03 23:12:43 UTC (rev 286771)
@@ -0,0 +1,74 @@
+--TEST--
+Test get_resource_type() function : usage variations - different data types as handle arg
+--FILE--
+<?php
+/* Prototype  : string get_resource_type  ( resource $handle  )
+ * Description:  Returns the resource type
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_resource_type() : variation test ***\n";
+
+class Hello {
+  public function SayHello($arg) {
+  	echo "Hello\n";
+  }
+}
+
+$res = fopen(__FILE__, "r");
+
+$vars = array(
+	"bool"=>false,
+	"int 10"=>10,
+	"float 10.5"=>10.5,
+	"string"=>"Hello World",
+	"array"=>array(1,2,3,4,5),
+	"NULL"=>NULL,
+	"Object"=>new Hello()
+);
+
+foreach($vars as $variation =>$object) {
+      echo "\n-- $variation --\n";
+      var_dump(get_resource_type($object));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_resource_type() : variation test ***
+
+-- bool --
+
+Warning: get_resource_type() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+-- int 10 --
+
+Warning: get_resource_type() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+-- float 10.5 --
+
+Warning: get_resource_type() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+-- string --
+
+Warning: get_resource_type() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
+
+-- array --
+
+Warning: get_resource_type() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+-- NULL --
+
+Warning: get_resource_type() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+-- Object --
+
+Warning: get_resource_type() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+===DONE===
\ No newline at end of file
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to