summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/TitleTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/TitleTest.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/phpunit/includes/TitleTest.php')
-rw-r--r--tests/phpunit/includes/TitleTest.php54
1 files changed, 19 insertions, 35 deletions
diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php
index fb58381f..d55f958b 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -14,6 +14,7 @@ class TitleTest extends MediaWikiTestCase {
'wgLang' => Language::factory( 'en' ),
'wgAllowUserJs' => false,
'wgDefaultLanguageVariant' => false,
+ 'wgMetaNamespace' => 'Project',
) );
}
@@ -324,36 +325,19 @@ class TitleTest extends MediaWikiTestCase {
$whitelistRegexp = array( $whitelistRegexp );
}
+ $this->setMwGlobals( array(
+ // So User::isEveryoneAllowed( 'read' ) === false
+ 'wgGroupPermissions' => array( '*' => array( 'read' => false ) ),
+ 'wgWhitelistRead' => array( 'some random non sense title' ),
+ 'wgWhitelistReadRegexp' => $whitelistRegexp,
+ ) );
+
$title = Title::newFromDBkey( $source );
- global $wgGroupPermissions;
- $oldPermissions = $wgGroupPermissions;
- // Disallow all so we can ensure our regex works
- $wgGroupPermissions = array();
- $wgGroupPermissions['*']['read'] = false;
-
- global $wgWhitelistRead;
- $oldWhitelist = $wgWhitelistRead;
- // Undo any LocalSettings explicite whitelists so they won't cause a
- // failing test to succeed. Set it to some random non sense just
- // to make sure we properly test Title::checkReadPermissions()
- $wgWhitelistRead = array( 'some random non sense title' );
-
- global $wgWhitelistReadRegexp;
- $oldWhitelistRegexp = $wgWhitelistReadRegexp;
- $wgWhitelistReadRegexp = $whitelistRegexp;
-
- // Just use $wgUser which in test is a user object for '127.0.0.1'
- global $wgUser;
- // Invalidate user rights cache to take in account $wgGroupPermissions
- // change above.
- $wgUser->clearInstanceCache();
- $errors = $title->userCan( $action, $wgUser );
-
- // Restore globals
- $wgGroupPermissions = $oldPermissions;
- $wgWhitelistRead = $oldWhitelist;
- $wgWhitelistReadRegexp = $oldWhitelistRegexp;
+ // New anonymous user with no rights
+ $user = new User;
+ $user->mRights = array();
+ $errors = $title->userCan( $action, $user );
if ( is_bool( $expected ) ) {
# Forge the assertion message depending on the assertion expectation
@@ -428,14 +412,14 @@ class TitleTest extends MediaWikiTestCase {
public function testGetPageViewLanguage( $expected, $titleText, $contLang,
$lang, $variant, $msg = ''
) {
- global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs;
-
// Setup environnement for this test
- $wgLanguageCode = $contLang;
- $wgContLang = Language::factory( $contLang );
- $wgLang = Language::factory( $lang );
- $wgDefaultLanguageVariant = $variant;
- $wgAllowUserJs = true;
+ $this->setMwGlobals( array(
+ 'wgLanguageCode' => $contLang,
+ 'wgContLang' => Language::factory( $contLang ),
+ 'wgLang' => Language::factory( $lang ),
+ 'wgDefaultLanguageVariant' => $variant,
+ 'wgAllowUserJs' => true,
+ ) );
$title = Title::newFromText( $titleText );
$this->assertInstanceOf( 'Title', $title,