3 use Wikimedia\Http\HttpAcceptParser
;
6 * @covers Wikimedia\Http\HttpAcceptParser
8 * @author Daniel Kinzler
10 class HttpAcceptParserTest
extends \PHPUnit\Framework\TestCase
{
12 public function provideParseWeights() {
27 'Accept: application/vnd.php.serialized, application/rdf+xml',
28 [ 'application/vnd.php.serialized' => 1, 'application/rdf+xml' => 1 ]
31 'foo; q=0.2, xoo; q=0,text/n3',
32 [ 'text/n3' => 1, 'foo' => 0.2 ]
35 '*; q=0.2, */*; q=0.1,text/*',
36 [ 'text/*' => 1, '*' => 0.2, '*/*' => 0.1 ]
38 // TODO: nicely ignore additional type paramerters
40 // 'Foo; q=0.2, Xoo; level=3, Bar; charset=xyz; q=0.4',
41 // [ 'xoo' => 1, 'bar' => 0.4, 'foo' => 0.1 ]
47 * @dataProvider provideParseWeights
49 public function testParseWeights( $header, $expected ) {
50 $parser = new HttpAcceptParser();
51 $actual = $parser->parseWeights( $header );
53 $this->assertEquals( $expected, $actual ); // shouldn't be sensitive to order