22 $this->interfaceTitle = Title::newFromText(
"Special:PageDataRequestHandlerTest" );
24 $this->obLevel = ob_get_level();
30 while ( ob_get_level() > $this->obLevel ) {
35 $this->fail(
"Test changed output buffer level: was {$this->obLevel}" .
36 "before test, but $obLevel after test."
59 $request->response()->header(
'Status: 200 OK',
true, 200 );
61 foreach ( $headers as $name =>
$value ) {
70 $output->setTitle( $this->interfaceTitle );
79 $cases[] = [
'', [], [],
'!!', 400 ];
81 $cases[] = [
'', [
'target' =>
'Helsinki' ], [],
'!!', 303, [
'Location' =>
'!.+!' ] ];
84 foreach ( $cases as $c ) {
88 if ( isset( $case[1][
'target'] ) ) {
89 $case[0] .= $case[1][
'target'];
90 unset( $case[1][
'target'] );
93 $subpageCases[] = $case;
96 $cases = array_merge( $cases, $subpageCases );
100 [
'target' =>
'Helsinki' ],
101 [
'Accept' =>
'text/HTML' ],
104 [
'Location' =>
'!Helsinki$!' ]
110 'target' =>
'Helsinki',
111 'revision' =>
'4242',
113 [
'Accept' =>
'text/HTML' ],
116 [
'Location' =>
'!Helsinki(\?|&)oldid=4242!' ]
125 [
'Location' =>
'!Helsinki&action=raw!' ]
132 [
'Accept' =>
'text/foobar' ],
141 [
'Accept' =>
'text/HTML' ],
144 [
'Location' =>
'!Helsinki$!' ]
150 [
'Accept' =>
'text/HTML' ],
153 [
'Location' =>
'!Helsinki$!' ]
159 [
'Accept' =>
'text/HTML' ],
162 [
'Location' =>
'!AC/DC$!' ]
183 $expectedStatusCode = 200,
184 array $expectedHeaders = []
199 if (
$output->getRedirect() !==
'' ) {
204 $text = ob_get_contents();
207 $this->assertEquals( $expectedStatusCode,
$response->getStatusCode(),
'status code' );
208 $this->assertRegExp( $expectedOutput, $text,
'output' );
210 foreach ( $expectedHeaders as $name => $exp ) {
212 $this->assertNotNull(
$value,
"header: $name" );
213 $this->assertInternalType(
'string',
$value,
"header: $name" );
214 $this->assertRegExp( $exp,
$value,
"header: $name" );
218 $this->assertEquals( $expectedStatusCode,
$e->getStatusCode(),
'status code' );
219 $this->assertRegExp( $expectedOutput,
$e->getHTML(),
'error output' );
223 $this->assertSame(
'*',
$response->getHeader(
'Access-Control-Allow-Origin' ) );
227 $helsinki = Title::newFromText(
'Helsinki' );
229 'Accept Header of HTML' => [
231 [
'ACCEPT' =>
'text/html' ],
234 'Accept Header without weights' => [
236 [
'ACCEPT' =>
'*/*, text/html, text/x-wiki' ],
237 'Helsinki&action=raw'
239 'Accept Header with weights' => [
241 [
'ACCEPT' =>
'text/*; q=0.5, text/json; q=0.7, application/rdf+xml; q=0.8' ],
242 'Helsinki&action=raw'
244 'Accept Header accepting evertyhing and HTML' => [
246 [
'ACCEPT' =>
'text/html, */*' ],
247 'Helsinki&action=raw'
249 'No Accept Header' => [
252 'Helsinki&action=raw'
269 $expectedRedirectSuffix
278 $this->assertStringEndsWith(
279 $expectedRedirectSuffix,
An IContextSource implementation which will inherit context from another source but allow individual ...
WebRequest clone which takes values from a provided array.
Show an error that looks like an HTTP server error.
This class should be covered by a general architecture document which does not exist as of January 20...
PageDataRequestHandler PageData.
makeOutputPage(array $params, array $headers)
provideHttpContentNegotiation()
testHandleRequest( $subpage, array $params, array $headers, $expectedOutput, $expectedStatusCode=200, array $expectedHeaders=[])
handleRequestProvider
testHttpContentNegotiation(Title $title, array $headers, $expectedRedirectSuffix)
provideHttpContentNegotiation
Request handler implementing a data interface for mediawiki pages.
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
this hook is for auditing only $response
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
returning false will NOT prevent logging $e