<?php
+use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
parent::setUp();
ResourceLoader::clearCache();
}
+
protected function tearDown() {
parent::tearDown();
ResourceLoader::clearCache();
function ( $op ) {
$op->getContext()->setUser( $this->getTestUser()->getUser() );
} ],
- 'After Squid expiry' =>
+ 'After CDN expiry' =>
[ $lastModified, $lastModified, false,
- [ 'UseSquid' => true, 'SquidMaxage' => 3599 ] ],
+ [ 'UseCdn' => true, 'CdnMaxAge' => 3599 ] ],
'Hook allows cache use' =>
[ $lastModified + 1, $lastModified, true, [],
function ( $op, $that ) {
}
public function provideAdaptCdnTTL() {
- global $wgSquidMaxage;
+ global $wgCdnMaxAge;
$now = time();
self::$fakeTime = $now;
return [
'Five minutes from now' => [ [ $now + 300 ], IExpiringStore::TTL_MINUTE ],
'Five minutes ago, initial maxage four minutes' =>
[ [ $now - 300 ], 270, [ 'initialMaxage' => 240 ] ],
- 'A very long time ago' => [ [ $now - 1000000000 ], $wgSquidMaxage ],
+ 'A very long time ago' => [ [ $now - 1000000000 ], $wgCdnMaxAge ],
'Initial maxage zero' => [ [ $now - 300 ], 270, [ 'initialMaxage' => 0 ] ],
'false' => [ [ false ], IExpiringStore::TTL_MINUTE ],
$method = $class->getMethod( 'makeResourceLoaderLink' );
$method->setAccessible( true );
$ctx = new RequestContext();
- $ctx->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'fallback' ) );
+ $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
+ $ctx->setSkin( $skinFactory->makeSkin( 'fallback' ) );
$ctx->setLanguage( 'en' );
$out = new OutputPage( $ctx );
$nonce = $class->getProperty( 'CSPNonce' );
// Single only=scripts load
[
[ 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ],
- "<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
+ "<script nonce=\"secret\">(RLQ=window.RLQ||[]).push(function(){"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
. "});</script>"
],
// Private embed (only=scripts)
[
[ 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ],
- "<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
+ "<script nonce=\"secret\">(RLQ=window.RLQ||[]).push(function(){"
. "mw.test.baz({token:123});\nmw.loader.state({\"test.quux\":\"ready\"});"
. "});</script>"
],
// Load private module (combined)
[
[ 'test.quux', ResourceLoaderModule::TYPE_COMBINED ],
- "<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
+ "<script nonce=\"secret\">(RLQ=window.RLQ||[]).push(function(){"
. "mw.loader.implement(\"test.quux@1ev0ijv\",function($,jQuery,require,module){"
. "mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
. "\"]});});</script>"
// Load two modules in separate groups
[
[ [ 'test.group.foo', 'test.group.bar' ], ResourceLoaderModule::TYPE_COMBINED ],
- "<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
+ "<script nonce=\"secret\">(RLQ=window.RLQ||[]).push(function(){"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
. "});</script>"
// Set up stubs
$ctx = new RequestContext();
- $ctx->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'fallback' ) );
+ $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
+ $ctx->setSkin( $skinFactory->makeSkin( 'fallback' ) );
$ctx->setLanguage( 'en' );
$op = $this->getMockBuilder( OutputPage::class )
->setConstructorArgs( [ $ctx ] )