diff options
author | Eric Stenson <ericsten@php.net> | 2013-12-13 10:42:32 -0800 |
---|---|---|
committer | Eric Stenson <ericsten@php.net> | 2013-12-13 10:42:32 -0800 |
commit | 50377b5bf2bc4cd6f77816a9216e035d71bc2ec8 (patch) | |
tree | 85f90c53fb1f5e29f2a8e336961d33c90b658bec /tests/strings | |
parent | 41eaac3491cfcad02ebab5f86ece018d9e3c4cc6 (diff) | |
download | php-git-50377b5bf2bc4cd6f77816a9216e035d71bc2ec8.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/strings')
-rw-r--r-- | tests/strings/001.phpt | 19 |
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 |