16
16
17
17
class AcceptHeaderTest extends \PHPUnit_Framework_TestCase
18
18
{
19
+ public function testFirst ()
20
+ {
21
+ $ header = AcceptHeader::fromString ('text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c ' );
22
+ $ this ->assertSame ('text/html ' , $ header ->first ()->getValue ());
23
+ }
24
+
19
25
/**
20
26
* @dataProvider provideFromStringData
21
27
*/
@@ -30,6 +36,17 @@ public function testFromString($string, array $items)
30
36
$ this ->assertEquals ($ items , $ parsed );
31
37
}
32
38
39
+ public function provideFromStringData ()
40
+ {
41
+ return array (
42
+ array ('' , array ()),
43
+ array ('gzip ' , array (new AcceptHeaderItem ('gzip ' ))),
44
+ array ('gzip,deflate,sdch ' , array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' ))),
45
+ array ("gzip, deflate \t,sdch " , array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' ))),
46
+ array ('"this;should,not=matter" ' , array (new AcceptHeaderItem ('this;should,not=matter ' ))),
47
+ );
48
+ }
49
+
33
50
/**
34
51
* @dataProvider provideToStringData
35
52
*/
@@ -39,6 +56,16 @@ public function testToString(array $items, $string)
39
56
$ this ->assertEquals ($ string , (string ) $ header );
40
57
}
41
58
59
+ public function provideToStringData ()
60
+ {
61
+ return array (
62
+ array (array (), '' ),
63
+ array (array (new AcceptHeaderItem ('gzip ' )), 'gzip ' ),
64
+ array (array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' )), 'gzip,deflate,sdch ' ),
65
+ array (array (new AcceptHeaderItem ('this;should,not=matter ' )), 'this;should,not=matter ' ),
66
+ );
67
+ }
68
+
42
69
/**
43
70
* @dataProvider provideFilterData
44
71
*/
@@ -48,6 +75,13 @@ public function testFilter($string, $filter, array $values)
48
75
$ this ->assertEquals ($ values , array_keys ($ header ->all ()));
49
76
}
50
77
78
+ public function provideFilterData ()
79
+ {
80
+ return array (
81
+ array ('fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 ' , '/fr.*/ ' , array ('fr-FR ' , 'fr ' )),
82
+ );
83
+ }
84
+
51
85
/**
52
86
* @dataProvider provideSortingData
53
87
*/
@@ -57,24 +91,6 @@ public function testSorting($string, array $values)
57
91
$ this ->assertEquals ($ values , array_keys ($ header ->all ()));
58
92
}
59
93
60
- public function provideFromStringData ()
61
- {
62
- return array (
63
- array ('' , array ()),
64
- array ('gzip ' , array (new AcceptHeaderItem ('gzip ' ))),
65
- array ('gzip,deflate,sdch ' , array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' ))),
66
- array ("gzip, deflate \t,sdch " , array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' ))),
67
- array ('"this;should,not=matter" ' , array (new AcceptHeaderItem ('this;should,not=matter ' ))),
68
- );
69
- }
70
-
71
- public function provideFilterData ()
72
- {
73
- return array (
74
- array ('fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 ' , '/fr.*/ ' , array ('fr-FR ' , 'fr ' )),
75
- );
76
- }
77
-
78
94
public function provideSortingData ()
79
95
{
80
96
return array (
@@ -83,14 +99,4 @@ public function provideSortingData()
83
99
'order matters when q is equal2 ' => array ('*;q=0.3,utf-8;q=0.7,ISO-8859-1;q=0.7 ' , array ('utf-8 ' , 'ISO-8859-1 ' , '* ' )),
84
100
);
85
101
}
86
-
87
- public function provideToStringData ()
88
- {
89
- return array (
90
- array (array (), '' ),
91
- array (array (new AcceptHeaderItem ('gzip ' )), 'gzip ' ),
92
- array (array (new AcceptHeaderItem ('gzip ' ), new AcceptHeaderItem ('deflate ' ), new AcceptHeaderItem ('sdch ' )), 'gzip,deflate,sdch ' ),
93
- array (array (new AcceptHeaderItem ('this;should,not=matter ' )), 'this;should,not=matter ' ),
94
- );
95
- }
96
102
}
0 commit comments