@@ -97,21 +97,13 @@ public function testOperatorMatchesEntity()
97
97
98
98
public function testOperatorMatchesHexBytes ()
99
99
{
100
- $ stream1 = fopen ('php://temp ' , 'w+b ' );
101
- fwrite ($ stream1 , hex2bin ('DEADBEEF ' ));
102
- rewind ($ stream1 );
103
-
104
- $ stream2 = fopen ('php://temp ' , 'w+b ' );
105
- fwrite ($ stream2 , hex2bin ('90ABCDEF ' ));
106
- rewind ($ stream2 );
107
-
108
100
$ c = new Matches (['$$matchesHexBytes ' => 'DEADBEEF ' ]);
109
- $ this ->assertResult (true , $ c , $ stream1 , 'value matches hex bytes (root-level) ' );
110
- $ this ->assertResult (false , $ c , $ stream2 , 'value does not match hex bytes (root-level) ' );
101
+ $ this ->assertResult (true , $ c , hex2bin ( ' DEADBEEF ' ) , 'value matches hex bytes (root-level) ' );
102
+ $ this ->assertResult (false , $ c , hex2bin ( ' 90ABCDEF ' ) , 'value does not match hex bytes (root-level) ' );
111
103
112
104
$ c = new Matches (['x ' => ['$$matchesHexBytes ' => '90ABCDEF ' ]]);
113
- $ this ->assertResult (true , $ c , ['x ' => $ stream2 ], 'value matches hex bytes (embedded) ' );
114
- $ this ->assertResult (false , $ c , ['x ' => $ stream1 ], 'value does not match hex bytes (embedded) ' );
105
+ $ this ->assertResult (true , $ c , ['x ' => hex2bin ( ' 90ABCDEF ' ) ], 'value matches hex bytes (embedded) ' );
106
+ $ this ->assertResult (false , $ c , ['x ' => hex2bin ( ' DEADBEEF ' ) ], 'value does not match hex bytes (embedded) ' );
115
107
}
116
108
117
109
public function testOperatorUnsetOrMatches ()
@@ -174,14 +166,14 @@ public function errorMessageProvider()
174
166
{
175
167
return [
176
168
'assertEquals: type check (root-level) ' => [
177
- 'string is not expected type "integer " ' ,
178
- new Matches (1 ),
179
- ' 1 ' ,
169
+ 'boolean is not expected type "string " ' ,
170
+ new Matches (' foo ' ),
171
+ true ,
180
172
],
181
173
'assertEquals: type check (embedded) ' => [
182
- 'Field path "x": string is not expected type "integer " ' ,
183
- new Matches (['x ' => 1 ]),
184
- ['x ' => ' 1 ' ],
174
+ 'Field path "x": boolean is not expected type "string " ' ,
175
+ new Matches (['x ' => ' foo ' ]),
176
+ ['x ' => true ],
185
177
],
186
178
'assertEquals: comparison failure (root-level) ' => [
187
179
'Failed asserting that two strings are equal. ' ,
@@ -254,9 +246,6 @@ public function testOperatorSyntaxValidation($expectedMessage, Matches $constrai
254
246
255
247
public function operatorErrorMessageProvider ()
256
248
{
257
- $ entityMap = new EntityMap ();
258
- $ entityMap ->set ('notSession ' , 1 );
259
-
260
249
return [
261
250
'$$exists type ' => [
262
251
'$$exists requires bool ' ,
@@ -270,13 +259,13 @@ public function operatorErrorMessageProvider()
270
259
'$$type requires string or string[] ' ,
271
260
new Matches (['x ' => ['$$type ' => [1 ]]]),
272
261
],
262
+ '$$matchesEntity requires EntityMap ' => [
263
+ '$$matchesEntity requires EntityMap ' ,
264
+ new Matches (['x ' => ['$$matchesEntity ' => 'foo ' ]]),
265
+ ],
273
266
'$$matchesEntity type ' => [
274
267
'$$matchesEntity requires string ' ,
275
- new Matches (['x ' => ['$$matchesEntity ' => 1 ]]),
276
- ],
277
- '$$matchesEntity undefined entity ' => [
278
- 'No entity is defined for "undefined" ' ,
279
- new Matches (['$$matchesEntity ' => 'undefined ' ]),
268
+ new Matches (['x ' => ['$$matchesEntity ' => 1 ]], new EntityMap ()),
280
269
],
281
270
'$$matchesHexBytes type ' => [
282
271
'$$matchesHexBytes requires string ' ,
@@ -286,17 +275,13 @@ public function operatorErrorMessageProvider()
286
275
'$$matchesHexBytes requires pairs of hex chars ' ,
287
276
new Matches (['$$matchesHexBytes ' => 'f00 ' ]),
288
277
],
278
+ '$$sessionLsid requires EntityMap ' => [
279
+ '$$sessionLsid requires EntityMap ' ,
280
+ new Matches (['x ' => ['$$sessionLsid ' => 'foo ' ]]),
281
+ ],
289
282
'$$sessionLsid type ' => [
290
283
'$$sessionLsid requires string ' ,
291
- new Matches (['x ' => ['$$sessionLsid ' => 1 ]]),
292
- ],
293
- '$$sessionLsid undefined entity ' => [
294
- 'No entity is defined for "undefined" ' ,
295
- new Matches (['$$sessionLsid ' => 'undefined ' ]),
296
- ],
297
- '$$sessionLsid invalid entity ' => [
298
- '$$sessionLsid requires session entity ' ,
299
- new Matches (['x ' => ['$$sessionLsid ' => 'notSession ' ]], $ entityMap ),
284
+ new Matches (['x ' => ['$$sessionLsid ' => 1 ]], new EntityMap ()),
300
285
],
301
286
];
302
287
}
0 commit comments