MediaWiki
REL1_31
HttpAcceptParserTest.php
Go to the documentation of this file.
1
<?php
2
3
use
Wikimedia\Http\HttpAcceptParser
;
4
10
class
HttpAcceptParserTest
extends
\PHPUnit\Framework\TestCase {
11
12
public
function
provideParseWeights
() {
13
return
[
14
[
// #0
15
''
,
16
[]
17
],
18
[
// #1
19
'Foo/Bar'
,
20
[
'foo/bar'
=> 1 ]
21
],
22
[
// #2
23
'Accept: text/plain'
,
24
[
'text/plain'
=> 1 ]
25
],
26
[
// #3
27
'Accept: application/vnd.php.serialized, application/rdf+xml'
,
28
[
'application/vnd.php.serialized'
=> 1,
'application/rdf+xml'
=> 1 ]
29
],
30
[
// #4
31
'foo; q=0.2, xoo; q=0,text/n3'
,
32
[
'text/n3'
=> 1,
'foo'
=> 0.2 ]
33
],
34
[
// #5
35
'*; q=0.2, */*; q=0.1,text/*'
,
36
[
'text/*'
=> 1,
'*'
=> 0.2,
'*/*'
=> 0.1 ]
37
],
38
// TODO: nicely ignore additional type paramerters
39
//[ // #6
40
// 'Foo; q=0.2, Xoo; level=3, Bar; charset=xyz; q=0.4',
41
// [ 'xoo' => 1, 'bar' => 0.4, 'foo' => 0.1 ]
42
//],
43
];
44
}
45
49
public
function
testParseWeights
(
$header
, $expected ) {
50
$parser
=
new
HttpAcceptParser
();
51
$actual =
$parser
->parseWeights(
$header
);
52
53
$this->assertEquals( $expected, $actual );
// shouldn't be sensitive to order
54
}
55
56
}
HttpAcceptParserTest
Wikimedia\Http\HttpAcceptParser.
Definition
HttpAcceptParserTest.php:10
HttpAcceptParserTest\provideParseWeights
provideParseWeights()
Definition
HttpAcceptParserTest.php:12
HttpAcceptParserTest\testParseWeights
testParseWeights( $header, $expected)
provideParseWeights
Definition
HttpAcceptParserTest.php:49
Wikimedia\Http\HttpAcceptParser
Definition
HttpAcceptParser.php:13
$parser
do that in ParserLimitReportFormat instead $parser
Definition
hooks.txt:2603
$header
$header
Definition
updateCredits.php:35
tests
phpunit
includes
libs
http
HttpAcceptParserTest.php
Generated on Mon Nov 25 2024 15:36:25 for MediaWiki by
1.10.0