jenkins-bot has submitted this change and it was merged.

Change subject: Always enable red links in alpha
......................................................................


Always enable red links in alpha

* Enable/disable red links in stable and beta depending on the
  wgMFShowRedLinks and wgMFShowRedLinksAnon configuration variables
* Enable red links in alpha for all users

Change-Id: Ib8438a4d8a936e76ac0b1bed06197828c2cee465
---
M includes/MobileFrontend.hooks.php
M includes/config/Editing.php
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaAlpha.php
M tests/phpunit/skins/SkinMinervaAlphaTest.php
A tests/phpunit/skins/SkinMinervaBetaTest.php
M tests/phpunit/skins/SkinMinervaTest.php
A tests/phpunit/skins/SkinTest.php
8 files changed, 134 insertions(+), 80 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 3e010ee..1b0fdff 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -783,6 +783,7 @@
                                        'MobileFormatterTest.php',
                                        'skins/SkinMinervaTest.php',
                                        'skins/SkinMinervaAlphaTest.php',
+                                       'skins/SkinMinervaBetaTest.php',
                                        'specials/MobileSpecialPageTest.php',
                                        'specials/SpecialMobileDiffTest.php',
                                )
diff --git a/includes/config/Editing.php b/includes/config/Editing.php
index b25bd3f..1ded5e8 100644
--- a/includes/config/Editing.php
+++ b/includes/config/Editing.php
@@ -4,15 +4,14 @@
 }
 
 /**
- * Specify whether to show redlinks (page doesn't exist) for logged in users 
using stable mode.
- * This hasn't any effect to beta and alpha mode!
- * This variable is temporary only.
+ * Specify whether to show red links (page doesn't exist) for logged in users
+ * using stable or beta mode. Red links are always shown in alpha mode.
  */
 $wgMFShowRedLinks = false;
 
 /**
- * Specify whether show redlinks (page doesn't exist) for anonymous users 
using stable mode.
- * This hasn't any effect to beta and alpha mode!
+ * Specify whether to show red links (page doesn't exist) for anonymous users
+ * using stable or beta mode. Red links are always shown in alpha mode.
  */
 $wgMFShowRedLinksAnon = false;
 
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 12996eb..c90fde8 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -852,20 +852,9 @@
                        $vars['wgMFIsLoggedInUserBlockedFromPage'] = 
$user->isBlockedFrom( $title );
                }
 
-               // init with false
-               $vars['wgMFShowRedLinks'] = false;
-
-               // in beta redlinks are visible for logged in users (no matter 
what config vars say)
-               if ( $this->mobileContext->isBetaGroupMember() ) {
-                       if ( $user->isLoggedIn() ) {
-                               $vars['wgMFShowRedLinks'] = true;
-                       }
-               } elseif (
-                       ( $wgMFShowRedLinks && $user->isLoggedIn() ) // ...for 
logged in users
-                       || ( $wgMFShowRedLinksAnon && $user->isAnon() ) // 
...for anonymous users
-               ) {
-                       $vars['wgMFShowRedLinks'] = true;
-               }
+               $vars['wgMFShowRedLinks'] = $user->isLoggedIn()
+                       ? $wgMFShowRedLinks
+                       : $wgMFShowRedLinksAnon;
 
                // Get variables that are only needed in mobile mode
                if ( $this->isMobileMode ) {
diff --git a/includes/skins/SkinMinervaAlpha.php 
b/includes/skins/SkinMinervaAlpha.php
index 9b79713..34b2ca5 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -109,6 +109,7 @@
                $vars['wgMFDescription'] = $this->getOutput()->getProperty( 
'wgMFDescription' );
                $vars['wgWikiBasePropertyConfig'] = $wgWikiBasePropertyConfig;
                $vars['wgMFInfoboxConfig'] = $wgMFInfoboxConfig;
+               $vars['wgMFShowRedLinks'] = true;
 
                return $vars;
        }
diff --git a/tests/phpunit/skins/SkinMinervaAlphaTest.php 
b/tests/phpunit/skins/SkinMinervaAlphaTest.php
index 7184b64..56146b7 100644
--- a/tests/phpunit/skins/SkinMinervaAlphaTest.php
+++ b/tests/phpunit/skins/SkinMinervaAlphaTest.php
@@ -1,9 +1,12 @@
 <?php
 
+require_once __DIR__ . '/SkinTest.php';
+
 /**
  * @group MobileFrontend
+ * @group Database
  */
-class SkinMinervaAlphaTest extends MediaWikiTestCase {
+class SkinMinervaAlphaTest extends SkinTest {
        /**
         * Check, if context modules aren't arrays. They will be added as an 
array with modules to
         * to load, which doesn't allow arrays as values.
@@ -26,7 +29,7 @@
                $context->setTitle( Title::newFromText( 'UTPage' ) );
                MobileContext::singleton()->setMobileMode( 'alpha' );
 
-               $skin = new SkinMinervaAlpha;
+               $skin = $this->getSkin();
                $skin->setContext( $context );
 
                $modules = $skin->getContextSpecificModules();
@@ -35,4 +38,26 @@
                        $this->assertFalse( is_array( $module ), 'Context 
specific modules can\'t be a arrays.' );
                }
        }
+
+       public function providerShowRedLinks() {
+               return array(
+                       // $wgShowRedLinks, $wgShowRedLinksAnon, $username, 
$expected
+                       array( false, false, 'UTSysop', true ),
+                       array( true, false, 'UTSysop', true ),
+                       array( false, true, 'UTSysop', true ),
+                       array( true, true, 'UTSysop', true ),
+                       array( false, false, 'NotLoggedIn', true ),
+                       array( true, false, 'NotLoggedIn', true ),
+                       array( false, true, 'NotLoggedIn', true ),
+                       array( true, true, 'NotLoggedIn', true ),
+               );
+       }
+
+       protected function getSkin() {
+               return new SkinMinervaAlpha();
+       }
+
+       protected function getMode() {
+               return 'alpha';
+       }
 }
diff --git a/tests/phpunit/skins/SkinMinervaBetaTest.php 
b/tests/phpunit/skins/SkinMinervaBetaTest.php
new file mode 100644
index 0000000..e8a1701
--- /dev/null
+++ b/tests/phpunit/skins/SkinMinervaBetaTest.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once __DIR__ . '/SkinTest.php';
+
+/**
+ * @group MobileFrontend
+ * @group Database
+ */
+class SkinMinervaBetaTest extends SkinTest
+{
+       public function providerShowRedLinks() {
+               return array(
+                       // $wgShowRedLinks, $wgShowRedLinksAnon, $username, 
$expected
+                       array( false, false, 'UTSysop', false ),
+                       array( true, false, 'UTSysop', true ),
+                       array( false, true, 'UTSysop', false ),
+                       array( true, true, 'UTSysop', true ),
+                       array( false, false, 'NotLoggedIn', false ),
+                       array( true, false, 'NotLoggedIn', false ),
+                       array( false, true, 'NotLoggedIn', true ),
+                       array( true, true, 'NotLoggedIn', true ),
+               );
+       }
+
+       protected function getSkin() {
+               return new SkinMinervaBeta();
+       }
+
+       protected function getMode() {
+               return 'beta';
+       }
+}
diff --git a/tests/phpunit/skins/SkinMinervaTest.php 
b/tests/phpunit/skins/SkinMinervaTest.php
index 0e443e6..9787fc1 100644
--- a/tests/phpunit/skins/SkinMinervaTest.php
+++ b/tests/phpunit/skins/SkinMinervaTest.php
@@ -1,71 +1,32 @@
 <?php
 
+require_once __DIR__ . '/SkinTest.php';
+
 /**
  * @group MobileFrontend
  * @group Database
  */
-class SkinMinervaTest extends MediaWikiTestCase {
-       /**
-        * @dataProvider providerShowRedLinks
-        */
-       public function testGetSkinConfigVariables( $showRedLinks, 
$showRedLinksAnon,
-               $mode, $username, $expected
-       ) {
-               // set config variables, which we test here
-               $values = array(
-                       'wgMFShowRedLinks' => $showRedLinks,
-                       'wgMFShowRedLinksAnon' => $showRedLinksAnon,
-                       'wgMFEnableBeta' => true
+class SkinMinervaTest extends SkinTest
+{
+       public function providerShowRedLinks() {
+               return array(
+                       // $wgShowRedLinks, $wgShowRedLinksAnon, $username, 
$expected
+                       array( false, false, 'UTSysop', false ),
+                       array( true, false, 'UTSysop', true ),
+                       array( false, true, 'UTSysop', false ),
+                       array( true, true, 'UTSysop', true ),
+                       array( false, false, 'NotLoggedIn', false ),
+                       array( true, false, 'NotLoggedIn', false ),
+                       array( false, true, 'NotLoggedIn', true ),
+                       array( true, true, 'NotLoggedIn', true ),
                );
-               $this->setMwGlobals( $values );
-
-               // create our specific user object
-               $user = User::newFromName( $username );
-               $user->load();
-
-               // create a new RequestContext for this test case and set User 
and title
-               $context = new RequestContext;
-               $context->setUser( $user );
-               $context->setTitle( Title::newFromText( 'Main_page' ) );
-
-               // create SkinMinerva to test
-               $skin = new SkinMinerva;
-               $skin->setContext( $context );
-
-               // set the fake mobile mode
-               MobileContext::singleton()->setMobileMode( $mode );
-
-               // test now
-               $vars = $skin->getSkinConfigVariables();
-               $this->assertEquals( $expected, $vars['wgMFShowRedLinks'] );
        }
 
-       /**
-        * Provides test data for testgetSkinConfigVariables()
-        */
-       public function providerShowRedLinks() {
-               // UTSysop is logged in, NotLoggedIn isn't
-               // $wgMFShowRedLinks, $wgMFShowRedLinksAnon, mobile mode, user, 
expected
-               return array(
-                       // test in stable mode
-                       array( false, false, 'stable', 'UTSysop', false ),
-                       array( true, false, 'stable', 'UTSysop', true ),
-                       array( false, true, 'stable', 'UTSysop', false ),
-                       array( true, true, 'stable', 'UTSysop', true ),
-                       array( false, false, 'stable', 'NotLoggedIn', false ),
-                       array( true, false, 'stable', 'NotLoggedIn', false ),
-                       array( false, true, 'stable', 'NotLoggedIn', true ),
-                       array( true, true, 'stable', 'NotLoggedIn', true ),
+       protected function getSkin() {
+               return new SkinMinerva();
+       }
 
-                       // test in beta mode
-                       array( false, false, 'beta', 'NotLoggedIn', false ),
-                       array( true, false, 'beta', 'NotLoggedIn', false ),
-                       array( false, true, 'beta', 'NotLoggedIn', false ),
-                       array( true, true, 'beta', 'NotLoggedIn', false ),
-                       array( false, false, 'beta', 'UTSysop', true ),
-                       array( true, false, 'beta', 'UTSysop', true ),
-                       array( false, true, 'beta', 'UTSysop', true ),
-                       array( true, true, 'beta', 'UTSysop', true ),
-               );
+       protected function getMode() {
+               return 'stable';
        }
 }
diff --git a/tests/phpunit/skins/SkinTest.php b/tests/phpunit/skins/SkinTest.php
new file mode 100644
index 0000000..fa830d2
--- /dev/null
+++ b/tests/phpunit/skins/SkinTest.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * A set of test cases that all skin tests must perform.
+ */
+abstract class SkinTest extends MediaWikiTestCase {
+
+       /**
+        * @dataProvider providerShowRedLinks
+        */
+       public function testRedLinks( $showRedLinks, $showRedLinksAnon, 
$username, $expected ) {
+               // set config variables, which we test here
+               $values = array(
+                       'wgMFShowRedLinks' => $showRedLinks,
+                       'wgMFShowRedLinksAnon' => $showRedLinksAnon,
+                       'wgMFEnableBeta' => true
+               );
+               $this->setMwGlobals( $values );
+
+               // create our specific user object
+               $user = User::newFromName( $username );
+               $user->load();
+
+               // create a new RequestContext for this test case and set User 
and title
+               $context = new RequestContext;
+               $context->setUser( $user );
+               $context->setTitle( Title::newFromText( 'Main_page' ) );
+
+               // create SkinMinerva to test
+               $skin = $this->getSkin();
+               $skin->setContext( $context );
+
+               // set the fake mobile mode
+               MobileContext::singleton()->setMobileMode( $this->getMode() );
+
+               // test now
+               $vars = $skin->getSkinConfigVariables();
+               $this->assertEquals( $expected, $vars['wgMFShowRedLinks'] );
+       }
+
+       abstract public function providerShowRedLinks();
+
+       abstract protected function getSkin();
+
+       abstract protected function getMode();
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/183038
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8438a4d8a936e76ac0b1bed06197828c2cee465
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to