32 if ( isset(
$args[
'printableQuery'] ) ) {
33 $queryData[
'printable'] =
$args[
'printableQuery'];
36 if ( isset(
$args[
'handheldQuery'] ) ) {
37 $queryData[
'handheld'] =
$args[
'handheldQuery'];
40 $fauxRequest =
new FauxRequest( $queryData,
false );
42 'wgRequest' => $fauxRequest,
46 $this->assertSame(
$args[
'expectedReturn'], $actualReturn,
$args[
'message'] );
55 'printableQuery' =>
'1',
57 'expectedReturn' => null,
58 'message' =>
'On printable request, screen returns null'
62 'printableQuery' =>
'1',
63 'media' => self::SCREEN_MEDIA_QUERY,
64 'expectedReturn' => null,
65 'message' =>
'On printable request, screen media query returns null'
69 'printableQuery' =>
'1',
70 'media' => self::SCREEN_ONLY_MEDIA_QUERY,
71 'expectedReturn' => null,
72 'message' =>
'On printable request, screen media query with only returns null'
76 'printableQuery' =>
'1',
78 'expectedReturn' =>
'',
79 'message' =>
'On printable request, media print returns empty string'
90 'expectedReturn' =>
'screen',
91 'message' =>
'On screen request, screen media type is preserved'
95 'media' =>
'handheld',
96 'expectedReturn' =>
'handheld',
97 'message' =>
'On screen request, handheld media type is preserved'
101 'media' => self::SCREEN_MEDIA_QUERY,
102 'expectedReturn' => self::SCREEN_MEDIA_QUERY,
103 'message' =>
'On screen request, screen media query is preserved.'
107 'media' => self::SCREEN_ONLY_MEDIA_QUERY,
108 'expectedReturn' => self::SCREEN_ONLY_MEDIA_QUERY,
109 'message' =>
'On screen request, screen media query with only is preserved.'
114 'expectedReturn' =>
'print',
115 'message' =>
'On screen request, print media type is preserved'
125 'handheldQuery' =>
'1',
126 'media' =>
'handheld',
127 'expectedReturn' =>
'',
128 'message' =>
'On request with handheld querystring and media is handheld, returns empty string'
132 'handheldQuery' =>
'1',
134 'expectedReturn' => null,
135 'message' =>
'On request with handheld querystring and media is screen, returns null'
145 "<script>(window.RLQ=window.RLQ||[]).push(function(){"
146 .
'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
152 '<script async="" src="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.raw&only=scripts&skin=fallback"></script>'
159 '<link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback"/>'
164 "<script>(window.RLQ=window.RLQ||[]).push(function(){"
165 .
"mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});"
171 "<script>(window.RLQ=window.RLQ||[]).push(function(){"
172 .
"mw.loader.implement(\"test.quux\",function($,jQuery,require,module){"
173 .
"mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
174 .
"\"]});});</script>"
184 '<noscript><link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.noscript&only=styles&skin=fallback"/></noscript>'
189 "<script>(window.RLQ=window.RLQ||[]).push(function(){"
190 .
'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
192 .
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
193 .
'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
211 'wgResourceLoaderDebug' =>
false,
212 'wgLoadScript' =>
'http://127.0.0.1:8080/w/load.php',
214 $class =
new ReflectionClass(
'OutputPage' );
215 $method = $class->getMethod(
'makeResourceLoaderLink' );
216 $method->setAccessible(
true );
219 $ctx->setLanguage(
'en' );
221 $rl =
$out->getResourceLoader();
225 'script' =>
'mw.test.foo( { a: true } );',
226 'styles' =>
'.mw-test-foo { content: "style"; }',
229 'script' =>
'mw.test.bar( { a: true } );',
230 'styles' =>
'.mw-test-bar { content: "style"; }',
233 'script' =>
'mw.test.baz( { a: true } );',
234 'styles' =>
'.mw-test-baz { content: "style"; }',
237 'script' =>
'mw.test.baz( { token: 123 } );',
238 'styles' =>
'/* pref-animate=off */ .mw-icon { transition: none; }',
239 'group' =>
'private',
242 'script' =>
'mw.test.baz( { token: 123 } );',
246 'styles' =>
'.mw-test-noscript { content: "style"; }',
247 'group' =>
'noscript',
250 'styles' =>
'.mw-group-bar { content: "style"; }',
254 'styles' =>
'.mw-group-foo { content: "style"; }',
258 $links = $method->invokeArgs(
$out,
$args );
259 $actualHtml = implode(
"\n", $links[
'html'] );
260 $this->assertEquals( $expectedHtml, $actualHtml );
271 $outputPage = $this->getMockBuilder(
'OutputPage' )
273 ->setMethods( [
'getCacheVaryCookies' ] )
275 $outputPage->expects( $this->any() )
276 ->method(
'getCacheVaryCookies' )
277 ->will( $this->returnValue( [] ) );
280 foreach ( $calls
as $call ) {
281 call_user_func_array( [ $outputPage,
'addVaryHeader' ], $call );
283 $this->assertEquals( $vary, $outputPage->getVaryHeader(),
'Vary:' );
284 $this->assertEquals(
$key, $outputPage->getKeyHeader(),
'Key:' );
300 [
'Accept-Language' ],
303 'Vary: Cookie, Accept-Language',
304 'Key: Cookie,Accept-Language',
308 [
'Cookie', [
'param=phpsessid' ] ],
309 [
'Accept-Language', [
'substr=en' ] ],
311 'Vary: Cookie, Accept-Language',
312 'Key: Cookie;param=phpsessid,Accept-Language;substr=en',
316 [
'Cookie', [
'param=phpsessid',
'param=userId' ] ],
319 'Key: Cookie;param=phpsessid;param=userId',
323 [
'Cookie', [
'param=phpsessid' ] ],
324 [
'Cookie', [
'param=phpsessid' ] ],
325 [
'Accept-Language', [
'substr=en',
'substr=en' ] ],
327 'Vary: Cookie, Accept-Language',
328 'Key: Cookie;param=phpsessid,Accept-Language;substr=en',
332 [
'Cookie', [
'param=phpsessid' ] ],
333 [
'Cookie', [
'param=userId' ] ],
336 'Key: Cookie;param=phpsessid;param=userId',
351 $this->assertFalse( $outputPage->haveCacheVaryCookies() );
355 $this->assertFalse( $outputPage->haveCacheVaryCookies() );
358 $request->setCookie(
'Token',
'123' );
359 $this->assertTrue( $outputPage->haveCacheVaryCookies() );
This class generates message blobs for use by ResourceLoader modules.
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 $out
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Group all the pieces relevant to the context of a request into one instance.
assertTransformCssMediaCase($args)
Tests a particular case of transformCssMedia, using the given input, globals, expected return...
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
const SCREEN_ONLY_MEDIA_QUERY
error also a ContextSource you ll probably need to make sure the header is varied on such as when responding to a resource loader request or generating HTML output & $resourceLoader
if(!isset($args[0])) $lang
testVaryHeaders($calls, $vary, $key)
provideVaryHeaders OutputPage::addVaryHeader OutputPage::getVaryHeader OutputPage::getKeyHeader ...
testPrintRequests()
Tests print requests OutputPage::transformCssMedia.
static provideMakeResourceLoaderLink()
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
This class should be covered by a general architecture document which does not exist as of January 20...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
testHaveCacheVaryCookies()
OutputPage::haveCacheVaryCookies.
error also a ContextSource you ll probably need to make sure the header is varied on $request
static transformCssMedia($media)
Transform "media" attribute based on request parameters.
testMakeResourceLoaderLink($args, $expectedHtml)
provideMakeResourceLoaderLink OutputPage::makeResourceLoaderLink ResourceLoader::makeLoaderImplementS...
testHandheld()
Tests handheld behavior OutputPage::transformCssMedia.
testScreenRequests()
Tests screen requests, without either query parameter set OutputPage::transformCssMedia.
MessageBlobStore that doesn't do anything.
updateModule($name, ResourceLoaderModule $module, $lang)
static newFromObject($object)
Return the same object, without access restrictions.
Dynamic JavaScript and CSS resource loading system.
insertMessageBlob($name, ResourceLoaderModule $module, $lang)
static getDefaultInstance()
Allows to change the fields on the form that will be generated $name