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");'
153 '<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"/>'
158 "<script>(window.RLQ=window.RLQ||[]).push(function(){"
159 .
"mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});"
174 'wgResourceLoaderDebug' =>
false,
175 'wgLoadScript' =>
'http://127.0.0.1:8080/w/load.php',
177 $class =
new ReflectionClass(
'OutputPage' );
178 $method = $class->getMethod(
'makeResourceLoaderLink' );
179 $method->setAccessible(
true );
182 $ctx->setLanguage(
'en' );
184 $rl =
$out->getResourceLoader();
188 'script' =>
'mw.test.foo( { a: true } );',
189 'styles' =>
'.mw-test-foo { content: "style"; }',
192 'script' =>
'mw.test.bar( { a: true } );',
193 'styles' =>
'.mw-test-bar { content: "style"; }',
196 'script' =>
'mw.test.baz( { a: true } );',
197 'styles' =>
'.mw-test-baz { content: "style"; }',
200 'script' =>
'mw.test.baz( { token: 123 } );',
201 'styles' =>
'/* pref-animate=off */ .mw-icon { transition: none; }',
202 'group' =>
'private',
205 $links = $method->invokeArgs(
$out,
$args );
206 $actualHtml = strval( $links );
207 $this->assertEquals( $expectedHtml, $actualHtml );
218 $outputPage = $this->getMockBuilder(
'OutputPage' )
220 ->setMethods( [
'getCacheVaryCookies' ] )
222 $outputPage->expects( $this->any() )
223 ->method(
'getCacheVaryCookies' )
224 ->will( $this->returnValue( [] ) );
227 foreach ( $calls
as $call ) {
228 call_user_func_array( [ $outputPage,
'addVaryHeader' ], $call );
230 $this->assertEquals( $vary, $outputPage->getVaryHeader(),
'Vary:' );
231 $this->assertEquals( $key, $outputPage->getKeyHeader(),
'Key:' );
247 [
'Accept-Language' ],
250 'Vary: Cookie, Accept-Language',
251 'Key: Cookie,Accept-Language',
255 [
'Cookie', [
'param=phpsessid' ] ],
256 [
'Accept-Language', [
'substr=en' ] ],
258 'Vary: Cookie, Accept-Language',
259 'Key: Cookie;param=phpsessid,Accept-Language;substr=en',
263 [
'Cookie', [
'param=phpsessid',
'param=userId' ] ],
266 'Key: Cookie;param=phpsessid;param=userId',
270 [
'Cookie', [
'param=phpsessid' ] ],
271 [
'Cookie', [
'param=phpsessid' ] ],
272 [
'Accept-Language', [
'substr=en',
'substr=en' ] ],
274 'Vary: Cookie, Accept-Language',
275 'Key: Cookie;param=phpsessid,Accept-Language;substr=en',
279 [
'Cookie', [
'param=phpsessid' ] ],
280 [
'Cookie', [
'param=userId' ] ],
283 'Key: Cookie;param=phpsessid;param=userId',
298 $this->assertFalse( $outputPage->haveCacheVaryCookies() );
302 $this->assertFalse( $outputPage->haveCacheVaryCookies() );
305 $request->setCookie(
'Token',
'123' );
306 $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
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)
See ResourceLoaderClientHtmlTest for full coverage.
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