3 use Wikimedia\Http\HttpAcceptParser
;
6 * @covers Wikimedia\Http\HttpAcceptParser
9 * @author Daniel Kinzler
11 class HttpAcceptParserTest
extends \PHPUnit_Framework_TestCase
{
13 public function provideParseWeights() {
28 'Accept: application/vnd.php.serialized, application/rdf+xml',
29 [ 'application/vnd.php.serialized' => 1, 'application/rdf+xml' => 1 ]
32 'foo; q=0.2, xoo; q=0,text/n3',
33 [ 'text/n3' => 1, 'foo' => 0.2 ]
36 '*; q=0.2, */*; q=0.1,text/*',
37 [ 'text/*' => 1, '*' => 0.2, '*/*' => 0.1 ]
39 // TODO: nicely ignore additional type paramerters
41 // 'Foo; q=0.2, Xoo; level=3, Bar; charset=xyz; q=0.4',
42 // [ 'xoo' => 1, 'bar' => 0.4, 'foo' => 0.1 ]
48 * @dataProvider provideParseWeights
50 public function testParseWeights( $header, $expected ) {
51 $parser = new HttpAcceptParser();
52 $actual = $parser->parseWeights( $header );
54 $this->assertEquals( $expected, $actual ); // shouldn't be sensitive to order