@@ -100,4 +100,31 @@ public function provideSortingData()
100
100
'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 ' , '* ' )),
101
101
);
102
102
}
103
+
104
+ /**
105
+ * @dataProvider provideDefaultValueData
106
+ */
107
+ public function testDefaultValue ($ acceptHeader , $ value , $ expectedQuality )
108
+ {
109
+ $ header = AcceptHeader::fromString ($ acceptHeader );
110
+ $ this ->assertSame ($ expectedQuality , $ header ->get ($ value )->getQuality ());
111
+ }
112
+
113
+ public function provideDefaultValueData ()
114
+ {
115
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, *;q=0.3 ' , 'text/xml ' , 0.3 );
116
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */*;q=0.3 ' , 'text/xml ' , 0.3 );
117
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */*;q=0.3 ' , 'text/html ' , 1.0 );
118
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */*;q=0.3 ' , 'text/plain ' , 0.5 );
119
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */*;q=0.3 ' , '* ' , 0.3 );
120
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */* ' , '* ' , 1.0 );
121
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */* ' , 'text/xml ' , 1.0 );
122
+ yield array ('text/plain;q=0.5, text/html, text/x-dvi;q=0.8, */* ' , 'text/* ' , 1.0 );
123
+ yield array ('text/plain;q=0.5, text/html, text/*;q=0.8, */* ' , 'text/* ' , 0.8 );
124
+ yield array ('text/plain;q=0.5, text/html, text/*;q=0.8, */* ' , 'text/html ' , 1.0 );
125
+ yield array ('text/plain;q=0.5, text/html, text/*;q=0.8, */* ' , 'text/x-dvi ' , 0.8 );
126
+ yield array ('*;q=0.3, ISO-8859-1;q=0.7, utf-8;q=0.7 ' , '* ' , 0.3 );
127
+ yield array ('*;q=0.3, ISO-8859-1;q=0.7, utf-8;q=0.7 ' , 'utf-8 ' , 0.7 );
128
+ yield array ('*;q=0.3, ISO-8859-1;q=0.7, utf-8;q=0.7 ' , 'SHIFT_JIS ' , 0.3 );
129
+ }
103
130
}
0 commit comments