Merge "Factor InterwikiLookup out of Interwiki class."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 18 May 2016 10:14:30 +0000 (10:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 18 May 2016 10:14:30 +0000 (10:14 +0000)
includes/actions/Action.php
tests/phpunit/includes/actions/ActionTest.php

index 839d7b2..4208b3b 100644 (file)
@@ -147,7 +147,7 @@ abstract class Action {
                // Trying to get a WikiPage for NS_SPECIAL etc. will result
                // in WikiPage::factory throwing "Invalid or virtual namespace -1 given."
                // For SpecialPages et al, default to action=view.
-               if ( !$context->canUseWikiPage() ) {
+               if ( $actionName === '' || !$context->canUseWikiPage() ) {
                        return 'view';
                }
 
index 4a30292..75c5b50 100644 (file)
@@ -56,8 +56,6 @@ class ActionTest extends MediaWikiTestCase {
                        // Null and non-existing values
                        [ 'null', null ],
                        [ 'undeclared', null ],
-                       [ '', null ],
-                       [ false, null ],
                ];
        }
 
@@ -137,22 +135,39 @@ class ActionTest extends MediaWikiTestCase {
                $this->assertType( $expected ?: 'null', $action );
        }
 
-       public function testNull_doesNotExist() {
-               $exists = Action::exists( null );
+       public function emptyActionProvider() {
+               return [
+                       [ null ],
+                       [ false ],
+                       [ '' ],
+               ];
+       }
+
+       /**
+        * @dataProvider emptyActionProvider
+        */
+       public function testEmptyAction_doesNotExist( $requestedAction ) {
+               $exists = Action::exists( $requestedAction );
 
                $this->assertFalse( $exists );
        }
 
-       public function testNull_defaultsToView() {
-               $context = $this->getContext( null );
+       /**
+        * @dataProvider emptyActionProvider
+        */
+       public function testEmptyAction_defaultsToView( $requestedAction ) {
+               $context = $this->getContext( $requestedAction );
                $actionName = Action::getActionName( $context );
 
                $this->assertEquals( 'view', $actionName );
        }
 
-       public function testNull_canNotBeInstantiated() {
+       /**
+        * @dataProvider emptyActionProvider
+        */
+       public function testEmptyAction_canNotBeInstantiated( $requestedAction ) {
                $page = $this->getPage();
-               $action = Action::factory( null, $page );
+               $action = Action::factory( $requestedAction, $page );
 
                $this->assertNull( $action );
        }