@@ -280,6 +280,59 @@ public function testWildcardWithDifferentParamsAndRanges()
280
280
$ this ->assertEquals ('21 ' , $ res ->getParams ()->version );
281
281
}
282
282
283
+ /**
284
+ * @group 3739
285
+ * @covers Accept::matchAcceptParams()
286
+ */
287
+ public function testParamRangesWithDecimals ()
288
+ {
289
+ $ acceptHeader = Accept::fromString ('Accept: application/vnd.com.example+xml; version=10 ' );
290
+ $ this ->assertFalse ($ acceptHeader ->match ('application/vnd.com.example+xml; version="\"3.1\"-\"3.1.1-DEV\"" ' ));
291
+ }
292
+
293
+ /**
294
+ * @group 3740
295
+ * @dataProvider provideParamRanges
296
+ * @covers Accept::matchAcceptParams()
297
+ * @covers Accept::getParametersFromFieldValuePart()
298
+ */
299
+ public function testParamRangesSupportDevStage ($ range , $ input , $ success )
300
+ {
301
+ $ acceptHeader = Accept::fromString (
302
+ 'Accept: application/vnd.com.example+xml; version=" ' . addslashes ($ input ) . '" '
303
+ );
304
+
305
+ $ res = $ acceptHeader ->match (
306
+ 'application/vnd.com.example+xml; version=" ' . addslashes ($ range ) . '" '
307
+ );
308
+
309
+ if ($ success ) {
310
+ $ this ->assertInstanceOf ('Zend\Http\Header\Accept\FieldValuePart\AcceptFieldValuePart ' , $ res );
311
+ } else {
312
+ $ this ->assertFalse ($ res );
313
+ }
314
+ }
315
+
316
+ /**
317
+ * @group 3740
318
+ * @return array
319
+ */
320
+ public function provideParamRanges ()
321
+ {
322
+ return array (
323
+ array ('"3.1.1-DEV"-3.1.1 ' , '3.1.1 ' , true ),
324
+ array ('3.1.0-"3.1.1-DEV" ' , '3.1.1 ' , false ),
325
+ array ('3.1.0-"3.1.1-DEV" ' , '3.1.1-DEV ' , true ),
326
+ array ('3.1.0-"3.1.1-DEV" ' , '3.1.2-DEV ' , false ),
327
+ array ('3.1.0-"3.1.1" ' , '3.1.2-DEV ' , false ),
328
+ array ('3.1.0-"3.1.1" ' , '3.1.0-DEV ' , false ),
329
+ array ('"3.1.0-DEV"-"3.1.1-BETA" ' , '3.1.0 ' , true ),
330
+ array ('"3.1.0-DEV"-"3.1.1-BETA" ' , '3.1.1 ' , false ),
331
+ array ('"3.1.0-DEV"-"3.1.1-BETA" ' , '3.1.1-BETA ' , true ),
332
+ array ('"3.1.0-DEV"-"3.1.1-BETA" ' , '3.1.0-DEV ' , true ),
333
+ );
334
+ }
335
+
283
336
public function testVersioningAndPriorization ()
284
337
{
285
338
$ acceptStr = 'Accept: text/html; version=23, text/json; version=15.3; q=0.9, ' .
@@ -301,14 +354,16 @@ public function testVersioningAndPriorization()
301
354
$ this ->assertEquals ($ value , $ res ->$ key );
302
355
}
303
356
304
- $ expected = (object ) array ('typeString ' => 'text/html ' ,
305
- 'type ' => 'text ' ,
306
- 'subtype ' => 'html ' ,
307
- 'subtypeRaw ' => 'html ' ,
308
- 'format ' => 'html ' ,
309
- 'priority ' => 0.4 ,
310
- 'params ' => array ('q ' => 0.4 , 'level ' => 2 ),
311
- 'raw ' => 'text/html;level=2;q=0.4 ' );
357
+ $ expected = (object ) array (
358
+ 'typeString ' => 'text/html ' ,
359
+ 'type ' => 'text ' ,
360
+ 'subtype ' => 'html ' ,
361
+ 'subtypeRaw ' => 'html ' ,
362
+ 'format ' => 'html ' ,
363
+ 'priority ' => 0.4 ,
364
+ 'params ' => array ('q ' => 0.4 , 'level ' => 2 ),
365
+ 'raw ' => 'text/html;level=2;q=0.4 '
366
+ );
312
367
313
368
$ str = 'text/html; version=17,text/json; version=15-16; q=0.5 ' ;
314
369
$ res = $ acceptHeader ->match ($ str );
0 commit comments