wiki.techinc.nl/tests/phpunit/includes/libs/http/HttpAcceptParserTest.php
Timo Tijhof bee9f4db96 Remove various redundant '@license' tags in file headers
Redundant given this is the project-wide license already,
especially in file headers that already include the GPL license
header.

This and other minor fixups based on feedback from Ie0cea0ef5027c7e5.

* Add @file where missing.
* Move @ingroup and @deprecated from file to class doc where needed.

Change-Id: I7067abb7abee1f0c238cb2536e16192e946d8daa
2018-01-12 18:15:11 +00:00

56 lines
1.2 KiB
PHP

<?php
use Wikimedia\Http\HttpAcceptParser;
/**
* @covers Wikimedia\Http\HttpAcceptParser
*
* @author Daniel Kinzler
*/
class HttpAcceptParserTest extends \PHPUnit_Framework_TestCase {
public function provideParseWeights() {
return [
[ // #0
'',
[]
],
[ // #1
'Foo/Bar',
[ 'foo/bar' => 1 ]
],
[ // #2
'Accept: text/plain',
[ 'text/plain' => 1 ]
],
[ // #3
'Accept: application/vnd.php.serialized, application/rdf+xml',
[ 'application/vnd.php.serialized' => 1, 'application/rdf+xml' => 1 ]
],
[ // #4
'foo; q=0.2, xoo; q=0,text/n3',
[ 'text/n3' => 1, 'foo' => 0.2 ]
],
[ // #5
'*; q=0.2, */*; q=0.1,text/*',
[ 'text/*' => 1, '*' => 0.2, '*/*' => 0.1 ]
],
// TODO: nicely ignore additional type paramerters
//[ // #6
// 'Foo; q=0.2, Xoo; level=3, Bar; charset=xyz; q=0.4',
// [ 'xoo' => 1, 'bar' => 0.4, 'foo' => 0.1 ]
//],
];
}
/**
* @dataProvider provideParseWeights
*/
public function testParseWeights( $header, $expected ) {
$parser = new HttpAcceptParser();
$actual = $parser->parseWeights( $header );
$this->assertEquals( $expected, $actual ); // shouldn't be sensitive to order
}
}