Add tests for disabled actions in ActionTest
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 17 Jul 2014 07:42:19 +0000 (09:42 +0200)
committerThiemo Mättig <thiemo.maettig@wikimedia.de>
Tue, 22 Jul 2014 11:55:44 +0000 (13:55 +0200)
Change-Id: I2c742fca0fa87604c1d503b938ecc495aafd8376

tests/phpunit/includes/actions/ActionTest.php

index 1297af3..4eb30ec 100644 (file)
@@ -16,6 +16,7 @@ class ActionTest extends MediaWikiTestCase {
                $context = $this->getContext();
                $this->setMwGlobals( 'wgActions', array(
                        'null' => null,
+                       'disabled' => false,
                        'dummy' => true,
                        'string' => 'NamedDummyAction',
                        'declared' => 'NonExistingClassName',
@@ -98,6 +99,26 @@ class ActionTest extends MediaWikiTestCase {
                $this->assertType( $expected ?: 'null', $action );
        }
 
+       public function testDisabledAction_exists() {
+               $exists = Action::exists( 'disabled' );
+
+               $this->assertTrue( $exists );
+       }
+
+       public function testDisabledAction_isNotResolved() {
+               $context = $this->getContext( 'disabled' );
+               $actionName = Action::getActionName( $context );
+
+               $this->assertEquals( 'nosuchaction', $actionName );
+       }
+
+       public function testDisabledAction_factoryReturnsFalse() {
+               $context = $this->getContext( 'disabled' );
+               $action = Action::factory( 'disabled', $context->getWikiPage(), $context );
+
+               $this->assertFalse( $action );
+       }
+
        public function dummyActionCallback() {
                $context = $this->getContext();
                return new CalledDummyAction( $context->getWikiPage(), $context );