Skip to content

Commit 330168a

Browse files
EricSten-MSFTlaruence
authored andcommitted
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().
1 parent ef73f85 commit 330168a

File tree

14 files changed

+59
-44
lines changed

14 files changed

+59
-44
lines changed

Zend/tests/bug41421.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ Warning: feof(): wrapper::stream_eof is not implemented! Assuming EOF in %s on l
2424
Fatal error: Uncaught exception 'Exception' in %s:%d
2525
Stack trace:
2626
#0 [internal function]: wrapper->stream_eof()
27-
#1 %s(%d): feof(Resource id #6)
27+
#1 %s(%d): feof(Resource id #%d)
2828
#2 {main}
2929
thrown in %s on line %d

ext/session/tests/session_name_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,6 @@ string(12) "Hello World!"
231231
-- Iteration 24 --
232232

233233
Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d
234-
resource(5) of type (stream)
234+
resource(%d) of type (stream)
235235
NULL
236236
Done

ext/standard/tests/array/each.phpt

4 Bytes
Binary file not shown.

ext/standard/tests/file/007_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool(false)
7676
Warning: fopen() expects at least 2 parameters, 0 given in %s on line %d
7777
bool(false)
7878

79-
Warning: fclose(): 5 is not a valid stream resource in %s on line %d
79+
Warning: fclose(): %d is not a valid stream resource in %s on line %d
8080
bool(false)
8181

8282
Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d
@@ -85,7 +85,7 @@ bool(false)
8585
Warning: fclose() expects exactly 1 parameter, 0 given in %s on line %d
8686
bool(false)
8787

88-
Warning: feof(): 5 is not a valid stream resource in %s on line %d
88+
Warning: feof(): %d is not a valid stream resource in %s on line %d
8989
bool(false)
9090

9191
Warning: feof() expects parameter 1 to be resource, string given in %s on line %d

ext/standard/tests/file/fgetss_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool(false)
9898
Warning: fgetss() expects parameter 1 to be resource, object given in %s on line %d
9999
bool(false)
100100
-- Testing fgetss() with closed/unset file handle --
101-
Warning: fgetss(): 5 is not a valid stream resource in %s on line %d
101+
Warning: fgetss(): %d is not a valid stream resource in %s on line %d
102102
bool(false)
103103

104104
Warning: fgetss() expects parameter 1 to be resource, null given in %s on line %d

ext/standard/tests/file/ftruncate_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Warning: ftruncate() expects parameter 1 to be resource, object given in %s on l
114114
bool(false)
115115
-- Testing ftruncate() with closed/unset file handle --
116116

117-
Warning: ftruncate(): 5 is not a valid stream resource in %s on line %d
117+
Warning: ftruncate(): %d is not a valid stream resource in %s on line %d
118118
bool(false)
119119
int(36)
120120

ext/standard/tests/general_functions/floatval.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ float(-5000000)
157157
*** Testing floatval() on non floating types ***
158158
float(-2147483648)
159159
float(2147483648)
160-
float(5)
161-
float(6)
160+
float(%d)
161+
float(%d)
162162
float(0)
163163
float(1)
164164
float(-1300)
@@ -175,8 +175,8 @@ float(0)
175175
*** Testing doubleval() on non floating types ***
176176
float(-2147483648)
177177
float(2147483648)
178-
float(5)
179-
float(6)
178+
float(%d)
179+
float(%d)
180180
float(0)
181181
float(1)
182182
float(-1300)

ext/standard/tests/general_functions/gettype_settype_basic.phpt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ int(0)
232232
string(7) "integer"
233233
-- Iteration 12 --
234234
bool(true)
235-
int(5)
235+
int(%d)
236236
string(7) "integer"
237237
-- Iteration 13 --
238238
bool(true)
239-
int(6)
239+
int(%d)
240240
string(7) "integer"
241241
-- Iteration 14 --
242242
8: Object of class point could not be converted to int
@@ -291,11 +291,11 @@ int(0)
291291
string(7) "integer"
292292
-- Iteration 12 --
293293
bool(true)
294-
int(5)
294+
int(%d)
295295
string(7) "integer"
296296
-- Iteration 13 --
297297
bool(true)
298-
int(6)
298+
int(%d)
299299
string(7) "integer"
300300
-- Iteration 14 --
301301
8: Object of class point could not be converted to int
@@ -350,11 +350,11 @@ float(0)
350350
string(6) "double"
351351
-- Iteration 12 --
352352
bool(true)
353-
float(5)
353+
float(%d)
354354
string(6) "double"
355355
-- Iteration 13 --
356356
bool(true)
357-
float(6)
357+
float(%d)
358358
string(6) "double"
359359
-- Iteration 14 --
360360
8: Object of class point could not be converted to double
@@ -409,11 +409,11 @@ float(0)
409409
string(6) "double"
410410
-- Iteration 12 --
411411
bool(true)
412-
float(5)
412+
float(%d)
413413
string(6) "double"
414414
-- Iteration 13 --
415415
bool(true)
416-
float(6)
416+
float(%d)
417417
string(6) "double"
418418
-- Iteration 14 --
419419
8: Object of class point could not be converted to double
@@ -610,12 +610,12 @@ string(6) "string"
610610
-- Iteration 12 --
611611
2: settype(): Cannot convert to resource type
612612
bool(false)
613-
resource(5) of type (stream)
613+
resource(%d) of type (stream)
614614
string(8) "resource"
615615
-- Iteration 13 --
616616
2: settype(): Cannot convert to resource type
617617
bool(false)
618-
resource(6) of type (stream)
618+
resource(%d) of type (stream)
619619
string(8) "resource"
620620
-- Iteration 14 --
621621
2: settype(): Cannot convert to resource type
@@ -716,14 +716,14 @@ string(5) "array"
716716
bool(true)
717717
array(1) {
718718
[0]=>
719-
resource(5) of type (stream)
719+
resource(%d) of type (stream)
720720
}
721721
string(5) "array"
722722
-- Iteration 13 --
723723
bool(true)
724724
array(1) {
725725
[0]=>
726-
resource(6) of type (stream)
726+
resource(%d) of type (stream)
727727
}
728728
string(5) "array"
729729
-- Iteration 14 --
@@ -824,14 +824,14 @@ string(6) "object"
824824
bool(true)
825825
object(stdClass)#2 (1) {
826826
["scalar"]=>
827-
resource(5) of type (stream)
827+
resource(%d) of type (stream)
828828
}
829829
string(6) "object"
830830
-- Iteration 13 --
831831
bool(true)
832832
object(stdClass)#2 (1) {
833833
["scalar"]=>
834-
resource(6) of type (stream)
834+
resource(%d) of type (stream)
835835
}
836836
string(6) "object"
837837
-- Iteration 14 --
@@ -893,11 +893,11 @@ string(6) "string"
893893
string(6) "string"
894894
-- Iteration 12 --
895895
bool(true)
896-
string(14) "Resource id #5"
896+
string(14) "Resource id #%d"
897897
string(6) "string"
898898
-- Iteration 13 --
899899
bool(true)
900-
string(14) "Resource id #6"
900+
string(14) "Resource id #%d"
901901
string(6) "string"
902902
-- Iteration 14 --
903903
bool(true)

ext/standard/tests/general_functions/print_r.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,13 +1484,13 @@ object_class Object
14841484
*** Testing print_r() on resources ***
14851485

14861486
-- Iteration 1 --
1487-
Resource id #5
1488-
Resource id #5
1489-
Resource id #5
1487+
Resource id #%d
1488+
Resource id #%d
1489+
Resource id #%d
14901490
-- Iteration 2 --
1491-
Resource id #6
1492-
Resource id #6
1493-
Resource id #6
1491+
Resource id #%d
1492+
Resource id #%d
1493+
Resource id #%d
14941494
*** Testing print_r() on different combinations of scalar
14951495
and non-scalar variables ***
14961496

ext/standard/tests/general_functions/strval.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ string(0) ""
279279
-- Iteration 1 --
280280
string(6) "Object"
281281
-- Iteration 2 --
282-
string(14) "Resource id #5"
282+
string(14) "Resource id #%d"
283283
-- Iteration 3 --
284-
string(14) "Resource id #6"
284+
string(14) "Resource id #%d"
285285
-- Iteration 4 --
286286

287287
Notice: Array to string conversion in %sstrval.php on line %d

ext/standard/tests/general_functions/type.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ int(0)
105105
bool(true)
106106
int(0)
107107
bool(true)
108-
int(5)
108+
int(%d)
109109
bool(true)
110-
int(6)
110+
int(%d)
111111
string(54) "Object of class stdClass could not be converted to int"
112112
bool(true)
113113
int(%d)
@@ -128,9 +128,9 @@ float(0)
128128
bool(true)
129129
float(0)
130130
bool(true)
131-
float(5)
131+
float(%d)
132132
bool(true)
133-
float(6)
133+
float(%d)
134134
string(57) "Object of class stdClass could not be converted to double"
135135
bool(true)
136136
float(%d)

ext/standard/tests/general_functions/var_dump.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,9 @@ object(object_class)#13 (8) {
844844

845845
*** Testing var_dump() on resources ***
846846
-- Iteration 1 --
847-
resource(5) of type (stream)
847+
resource(%d) of type (stream)
848848
-- Iteration 2 --
849-
resource(6) of type (stream)
849+
resource(%d) of type (stream)
850850

851851
*** Testing var_dump() on different combinations of scalar
852852
and non-scalar variables ***
@@ -1227,9 +1227,9 @@ array(4) {
12271227
}
12281228
array(2) {
12291229
[0]=>
1230-
resource(5) of type (stream)
1230+
resource(%d) of type (stream)
12311231
[1]=>
1232-
resource(6) of type (stream)
1232+
resource(%d) of type (stream)
12331233
}
12341234
array(9) {
12351235
[0]=>
2 Bytes
Binary file not shown.

tests/strings/001.phpt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,23 @@ if ($ss == "\$'") {
177177
}
178178

179179

180-
echo "Testing uniqid: ";
180+
echo "Testing uniqid(true): ";
181+
$str = "prefix";
182+
$ui1 = uniqid($str, true);
183+
$ui2 = uniqid($str, true);
184+
185+
$len = 29;
186+
187+
if (strlen($ui1) == strlen($ui2) && strlen($ui1) == $len && $ui1 != $ui2) {
188+
echo("passed\n");
189+
} else {
190+
echo("failed!\n");
191+
}
192+
193+
echo "Testing uniqid(false): ";
181194
$str = "prefix";
182195
$ui1 = uniqid($str);
196+
usleep( 1 );
183197
$ui2 = uniqid($str);
184198

185199
$len = strncasecmp(PHP_OS, 'CYGWIN', 6) ? 19 : 29;
@@ -207,4 +221,5 @@ Testing ufirst: passed
207221
Testing strtr: passed
208222
Testing addslashes: passed
209223
Testing stripslashes: passed
210-
Testing uniqid: passed
224+
Testing uniqid(true): passed
225+
Testing uniqid(false): passed

0 commit comments

Comments
 (0)