summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Stenson <ericsten@php.net>2013-12-13 10:42:32 -0800
committerXinchen Hui <laruence@gmail.com>2013-12-15 16:51:21 +0800
commit330168a2477666212797095449029e78dcce0844 (patch)
treef2653b7dbbb14358f0dc42d8543b22bc4e9e9007 /tests
parentef73f85079e7563cb82afde35f0e89321257f0d9 (diff)
downloadphp-git-330168a2477666212797095449029e78dcce0844.tar.gz
Fix tests expecting specific resource IDs
When Wincache or APC are installed, the resource IDs are not the same. This is because Wincache takes a few resource objects for itself. As a result, these tests become false positives. On Windows boxes, the microtime precision is not granular enough to reliably register a difference if two calls to uniqid() are made concurrently. This is a fix to the uniqid() test to avoid the false positive when run on Windows machines. Also, added a test to exercise the 'more_entropy' variant of uniqid().
Diffstat (limited to 'tests')
-rw-r--r--tests/strings/001.phpt19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/strings/001.phpt b/tests/strings/001.phpt
index 3bfd3dbc30..98ceceb350 100644
--- a/tests/strings/001.phpt
+++ b/tests/strings/001.phpt
@@ -177,9 +177,23 @@ if ($ss == "\$'") {
}
-echo "Testing uniqid: ";
+echo "Testing uniqid(true): ";
+$str = "prefix";
+$ui1 = uniqid($str, true);
+$ui2 = uniqid($str, true);
+
+$len = 29;
+
+if (strlen($ui1) == strlen($ui2) && strlen($ui1) == $len && $ui1 != $ui2) {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+echo "Testing uniqid(false): ";
$str = "prefix";
$ui1 = uniqid($str);
+usleep( 1 );
$ui2 = uniqid($str);
$len = strncasecmp(PHP_OS, 'CYGWIN', 6) ? 19 : 29;
@@ -207,4 +221,5 @@ Testing ufirst: passed
Testing strtr: passed
Testing addslashes: passed
Testing stripslashes: passed
-Testing uniqid: passed
+Testing uniqid(true): passed
+Testing uniqid(false): passed