wharmby                                  Mon, 17 Aug 2009 14:22:02 +0000

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

Log:
New basic tests for uniqid(). Tested on Windows, Linux and Linux 64 bit

Changed paths:
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_basic.phpt
    A   
php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_error.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_basic.phpt
    A   
php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_error.phpt
    A   php/php-src/trunk/ext/standard/tests/general_functions/uniqid_basic.phpt
    A   php/php-src/trunk/ext/standard/tests/general_functions/uniqid_error.phpt

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_basic.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,73 @@
+--TEST--
+Test uniqid() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : basic functionality ***\n";
+
+echo "\nuniqid() without a prefix\n";
+var_dump(uniqid());
+var_dump(uniqid(null, true));
+var_dump(uniqid(null, false));
+echo "\n\n";
+
+echo "uniqid() with a prefix\n";
+
+// Use a fixed prefix so we can ensure length of o/p id is fixed
+$prefix = array (
+				99999,
+				"99999",
+				10.5e2,
+				null,
+				true,
+				false
+				);
+
+for ($i = 0; $i < count($prefix); $i++) {
+	var_dump(uniqid($prefix[$i]));
+	var_dump(uniqid($prefix[$i], true));
+	var_dump(uniqid($prefix[$i], false));
+	echo "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : basic functionality ***
+
+uniqid() without a prefix
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+
+uniqid() with a prefix
+string(18) "99999%s"
+string(28) "99999%s.%s"
+string(18) "99999%s"
+
+string(18) "999994%s"
+string(28) "999994%s.%s"
+string(18) "999994%s"
+
+string(17) "1050%s"
+string(27) "1050%s.%s"
+string(17) "1050%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+string(14) "1%s"
+string(24) "1%s.%s"
+string(14) "1%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+===DONE===
+
\ No newline at end of file

Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/uniqid_error.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,46 @@
+--TEST--
+Test uniqid() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : error conditions ***\n";
+
+echo "\n-- Testing uniqid() function with more than expected no. of arguments --\n";
+$prefix = null;
+$more_entropy = false;
+$extra_arg = false;
+var_dump(uniqid($prefix, $more_entropy, $extra_arg));
+
+echo "\n-- Testing uniqid() function with invalid values for \$prefix --\n";
+class class1{}
+$obj = new class1();
+$res = fopen(__FILE__, "r");
+$array = array(1,2,3);
+
+uniqid($array, false);
+uniqid($res, false);
+uniqid($obj, false);
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : error conditions ***
+
+-- Testing uniqid() function with more than expected no. of arguments --
+
+Warning: uniqid() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing uniqid() function with invalid values for $prefix --
+
+Warning: uniqid() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, resource given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, object given in %s on line %d
+===DONE===
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_basic.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_basic.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_basic.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,73 @@
+--TEST--
+Test uniqid() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : basic functionality ***\n";
+
+echo "\nuniqid() without a prefix\n";
+var_dump(uniqid());
+var_dump(uniqid(null, true));
+var_dump(uniqid(null, false));
+echo "\n\n";
+
+echo "uniqid() with a prefix\n";
+
+// Use a fixed prefix so we can ensure length of o/p id is fixed
+$prefix = array (
+				99999,
+				"99999",
+				10.5e2,
+				null,
+				true,
+				false
+				);
+
+for ($i = 0; $i < count($prefix); $i++) {
+	var_dump(uniqid($prefix[$i]));
+	var_dump(uniqid($prefix[$i], true));
+	var_dump(uniqid($prefix[$i], false));
+	echo "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : basic functionality ***
+
+uniqid() without a prefix
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+
+uniqid() with a prefix
+string(18) "99999%s"
+string(28) "99999%s.%s"
+string(18) "99999%s"
+
+string(18) "999994%s"
+string(28) "999994%s.%s"
+string(18) "999994%s"
+
+string(17) "1050%s"
+string(27) "1050%s.%s"
+string(17) "1050%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+string(14) "1%s"
+string(24) "1%s.%s"
+string(14) "1%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+===DONE===
+
\ No newline at end of file

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_error.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_error.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/uniqid_error.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,46 @@
+--TEST--
+Test uniqid() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : error conditions ***\n";
+
+echo "\n-- Testing uniqid() function with more than expected no. of arguments --\n";
+$prefix = null;
+$more_entropy = false;
+$extra_arg = false;
+var_dump(uniqid($prefix, $more_entropy, $extra_arg));
+
+echo "\n-- Testing uniqid() function with invalid values for \$prefix --\n";
+class class1{}
+$obj = new class1();
+$res = fopen(__FILE__, "r");
+$array = array(1,2,3);
+
+uniqid($array, false);
+uniqid($res, false);
+uniqid($obj, false);
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : error conditions ***
+
+-- Testing uniqid() function with more than expected no. of arguments --
+
+Warning: uniqid() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing uniqid() function with invalid values for $prefix --
+
+Warning: uniqid() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, resource given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, object given in %s on line %d
+===DONE===
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/uniqid_basic.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/uniqid_basic.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/uniqid_basic.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,73 @@
+--TEST--
+Test uniqid() function : basic functionality
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : basic functionality ***\n";
+
+echo "\nuniqid() without a prefix\n";
+var_dump(uniqid());
+var_dump(uniqid(null, true));
+var_dump(uniqid(null, false));
+echo "\n\n";
+
+echo "uniqid() with a prefix\n";
+
+// Use a fixed prefix so we can ensure length of o/p id is fixed
+$prefix = array (
+				99999,
+				"99999",
+				10.5e2,
+				null,
+				true,
+				false
+				);
+
+for ($i = 0; $i < count($prefix); $i++) {
+	var_dump(uniqid($prefix[$i]));
+	var_dump(uniqid($prefix[$i], true));
+	var_dump(uniqid($prefix[$i], false));
+	echo "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : basic functionality ***
+
+uniqid() without a prefix
+unicode(13) "%s"
+unicode(23) "%s.%s"
+unicode(13) "%s"
+
+
+uniqid() with a prefix
+unicode(18) "99999%s"
+unicode(28) "99999%s.%s"
+unicode(18) "99999%s"
+
+unicode(18) "999994%s"
+unicode(28) "999994%s.%s"
+unicode(18) "999994%s"
+
+unicode(17) "1050%s"
+unicode(27) "1050%s.%s"
+unicode(17) "1050%s"
+
+unicode(13) "%s"
+unicode(23) "%s.%s"
+unicode(13) "%s"
+
+unicode(14) "1%s"
+unicode(24) "1%s.%s"
+unicode(14) "1%s"
+
+unicode(13) "%s"
+unicode(23) "%s.%s"
+unicode(13) "%s"
+
+===DONE===
+
\ No newline at end of file

Added: php/php-src/trunk/ext/standard/tests/general_functions/uniqid_error.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/uniqid_error.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/uniqid_error.phpt	2009-08-17 14:22:02 UTC (rev 287412)
@@ -0,0 +1,46 @@
+--TEST--
+Test uniqid() function : error conditions
+--FILE--
+<?php
+/* Prototype  : string uniqid  ([ string $prefix= ""  [, bool $more_entropy= false  ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : error conditions ***\n";
+
+echo "\n-- Testing uniqid() function with more than expected no. of arguments --\n";
+$prefix = null;
+$more_entropy = false;
+$extra_arg = false;
+var_dump(uniqid($prefix, $more_entropy, $extra_arg));
+
+echo "\n-- Testing uniqid() function with invalid values for \$prefix --\n";
+class class1{}
+$obj = new class1();
+$res = fopen(__FILE__, "r");
+$array = array(1,2,3);
+
+uniqid($array, false);
+uniqid($res, false);
+uniqid($obj, false);
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : error conditions ***
+
+-- Testing uniqid() function with more than expected no. of arguments --
+
+Warning: uniqid() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing uniqid() function with invalid values for $prefix --
+
+Warning: uniqid() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string (Unicode or binary), object given in %s on line %d
+===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