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:
Paladox 2019-11-14 14:10:56 +00:00 committed by Florian Schmidt
parent 58654cf11a
commit 6ecc3fd4fc
3 changed files with 12 additions and 14 deletions

View file

@ -1,7 +1,7 @@
{
"require-dev": {
"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",
"mediawiki/minus-x": "0.3.1"
},

View file

@ -13,7 +13,7 @@ class Decisions {
private $geoLocation;
private $cache;
const CACHE_KEY = 'cookieWarningIpLookupCache:';
private const CACHE_KEY = 'cookieWarningIpLookupCache:';
/**
* @param Config $config

View file

@ -2,12 +2,14 @@
namespace CookieWarning\Tests;
use CommentStoreComment;
use CookieWarning\GeoLocation;
use CookieWarning\Hooks;
use DerivativeContext;
use FauxRequest;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
use MediaWikiLangTestCase;
use MessageCache;
use RequestContext;
use SkinTemplate;
use Title;
@ -19,13 +21,6 @@ use WikitextContent;
* @group Database
*/
class HooksTest extends MediaWikiLangTestCase {
/**
* @throws \MWException
*/
protected function setUp() {
parent::setUp();
MessageCache::singleton()->enable();
}
/**
* @dataProvider providerOnSkinTemplateOutputPageBeforeExec
@ -41,17 +36,20 @@ class HooksTest extends MediaWikiLangTestCase {
'wgCookieWarningForCountryCodes' => false,
'wgUseMediaWikiUIEverywhere' => true,
] );
MediaWikiServices::getInstance()->getMessageCache()->enable();
if ( $morelinkCookieWarningMsg ) {
$title = Title::newFromText( 'cookiewarning-more-link', NS_MEDIAWIKI );
$wikiPage = WikiPage::factory( $title );
$wikiPage->doEditContent( new WikitextContent( $morelinkCookieWarningMsg ),
"CookieWarning test" );
$pageUpdater = $wikiPage->newPageUpdater( \User::newFromName( 'UTSysop' ) );
$pageUpdater->setContent( SlotRecord::MAIN, new WikitextContent( $morelinkCookieWarningMsg ) );
$pageUpdater->saveRevision( CommentStoreComment::newUnsavedComment( 'CookieWarning test' ) );
}
if ( $morelinkCookiePolicyMsg ) {
$title = Title::newFromText( 'cookie-policy-link', NS_MEDIAWIKI );
$wikiPage = WikiPage::factory( $title );
$wikiPage->doEditContent( new WikitextContent( $morelinkCookiePolicyMsg ),
"CookieWarning test" );
$pageUpdater = $wikiPage->newPageUpdater( \User::newFromName( 'UTSysop' ) );
$pageUpdater->setContent( SlotRecord::MAIN, new WikitextContent( $morelinkCookiePolicyMsg ) );
$pageUpdater->saveRevision( CommentStoreComment::newUnsavedComment( 'CookieWarning test' ) );
}
$sk = new SkinTemplate();
$tpl = new \SkinFallbackTemplate();