mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-27 15:40:16 +00:00
Fix tests to be compatible with master again
Also fix tests relying on MessageCache. MessageCache is enabled in setup, however, as setMwGlobals is resetting services, it gets disabled again. Instead of setting the configuration to enable the use of database messages, let's enable the message cache after the last reset of services. Change-Id: Iff670def50ab15054099f7a1ca3adc119bd877ce
This commit is contained in:
parent
58654cf11a
commit
6ecc3fd4fc
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"jakub-onderka/php-parallel-lint": "1.0.0",
|
"jakub-onderka/php-parallel-lint": "1.0.0",
|
||||||
"mediawiki/mediawiki-codesniffer": "26.0.0",
|
"mediawiki/mediawiki-codesniffer": "28.0.0",
|
||||||
"jakub-onderka/php-console-highlighter": "0.3.2",
|
"jakub-onderka/php-console-highlighter": "0.3.2",
|
||||||
"mediawiki/minus-x": "0.3.1"
|
"mediawiki/minus-x": "0.3.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Decisions {
|
||||||
private $geoLocation;
|
private $geoLocation;
|
||||||
private $cache;
|
private $cache;
|
||||||
|
|
||||||
const CACHE_KEY = 'cookieWarningIpLookupCache:';
|
private const CACHE_KEY = 'cookieWarningIpLookupCache:';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
namespace CookieWarning\Tests;
|
namespace CookieWarning\Tests;
|
||||||
|
|
||||||
|
use CommentStoreComment;
|
||||||
use CookieWarning\GeoLocation;
|
use CookieWarning\GeoLocation;
|
||||||
use CookieWarning\Hooks;
|
use CookieWarning\Hooks;
|
||||||
use DerivativeContext;
|
use DerivativeContext;
|
||||||
use FauxRequest;
|
use FauxRequest;
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
use MediaWiki\Revision\SlotRecord;
|
||||||
use MediaWikiLangTestCase;
|
use MediaWikiLangTestCase;
|
||||||
use MessageCache;
|
|
||||||
use RequestContext;
|
use RequestContext;
|
||||||
use SkinTemplate;
|
use SkinTemplate;
|
||||||
use Title;
|
use Title;
|
||||||
|
@ -19,13 +21,6 @@ use WikitextContent;
|
||||||
* @group Database
|
* @group Database
|
||||||
*/
|
*/
|
||||||
class HooksTest extends MediaWikiLangTestCase {
|
class HooksTest extends MediaWikiLangTestCase {
|
||||||
/**
|
|
||||||
* @throws \MWException
|
|
||||||
*/
|
|
||||||
protected function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
MessageCache::singleton()->enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerOnSkinTemplateOutputPageBeforeExec
|
* @dataProvider providerOnSkinTemplateOutputPageBeforeExec
|
||||||
|
@ -41,17 +36,20 @@ class HooksTest extends MediaWikiLangTestCase {
|
||||||
'wgCookieWarningForCountryCodes' => false,
|
'wgCookieWarningForCountryCodes' => false,
|
||||||
'wgUseMediaWikiUIEverywhere' => true,
|
'wgUseMediaWikiUIEverywhere' => true,
|
||||||
] );
|
] );
|
||||||
|
MediaWikiServices::getInstance()->getMessageCache()->enable();
|
||||||
if ( $morelinkCookieWarningMsg ) {
|
if ( $morelinkCookieWarningMsg ) {
|
||||||
$title = Title::newFromText( 'cookiewarning-more-link', NS_MEDIAWIKI );
|
$title = Title::newFromText( 'cookiewarning-more-link', NS_MEDIAWIKI );
|
||||||
$wikiPage = WikiPage::factory( $title );
|
$wikiPage = WikiPage::factory( $title );
|
||||||
$wikiPage->doEditContent( new WikitextContent( $morelinkCookieWarningMsg ),
|
$pageUpdater = $wikiPage->newPageUpdater( \User::newFromName( 'UTSysop' ) );
|
||||||
"CookieWarning test" );
|
$pageUpdater->setContent( SlotRecord::MAIN, new WikitextContent( $morelinkCookieWarningMsg ) );
|
||||||
|
$pageUpdater->saveRevision( CommentStoreComment::newUnsavedComment( 'CookieWarning test' ) );
|
||||||
}
|
}
|
||||||
if ( $morelinkCookiePolicyMsg ) {
|
if ( $morelinkCookiePolicyMsg ) {
|
||||||
$title = Title::newFromText( 'cookie-policy-link', NS_MEDIAWIKI );
|
$title = Title::newFromText( 'cookie-policy-link', NS_MEDIAWIKI );
|
||||||
$wikiPage = WikiPage::factory( $title );
|
$wikiPage = WikiPage::factory( $title );
|
||||||
$wikiPage->doEditContent( new WikitextContent( $morelinkCookiePolicyMsg ),
|
$pageUpdater = $wikiPage->newPageUpdater( \User::newFromName( 'UTSysop' ) );
|
||||||
"CookieWarning test" );
|
$pageUpdater->setContent( SlotRecord::MAIN, new WikitextContent( $morelinkCookiePolicyMsg ) );
|
||||||
|
$pageUpdater->saveRevision( CommentStoreComment::newUnsavedComment( 'CookieWarning test' ) );
|
||||||
}
|
}
|
||||||
$sk = new SkinTemplate();
|
$sk = new SkinTemplate();
|
||||||
$tpl = new \SkinFallbackTemplate();
|
$tpl = new \SkinFallbackTemplate();
|
||||||
|
|
Loading…
Reference in a new issue