Merge "API: Handle "special" options in action=options"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiOptionsTest.php
index 3168f32..15bd8bb 100644 (file)
@@ -10,7 +10,7 @@
 class ApiOptionsTest extends MediaWikiLangTestCase {
 
        /** @var PHPUnit_Framework_MockObject_MockObject */
-       private $mUserMock ;
+       private $mUserMock;
        /** @var ApiOptions */
        private $mTested;
        private $mSession;
@@ -99,6 +99,12 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
                return true;
        }
 
+       /**
+        * @param IContextSource $context
+        * @param array|null $options
+        *
+        * @return array
+        */
        public function getOptionKinds( IContextSource $context, $options = null ) {
                // Match with above.
                $kinds = array(
@@ -110,6 +116,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
                        'testmultiselect-opt2' => 'registered-multiselect',
                        'testmultiselect-opt3' => 'registered-multiselect',
                        'testmultiselect-opt4' => 'registered-multiselect',
+                       'special' => 'special',
                );
 
                if ( $options === null ) {
@@ -383,6 +390,29 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
                $this->assertEquals( self::$Success, $response );
        }
 
+       public function testSpecialOption() {
+               $this->mUserMock->expects( $this->never() )
+                       ->method( 'resetOptions' );
+
+               $this->mUserMock->expects( $this->never() )
+                       ->method( 'saveSettings' );
+
+               $request = $this->getSampleRequest( array(
+                       'change' => 'special=1'
+               ) );
+
+               $response = $this->executeQuery( $request );
+
+               $this->assertEquals( array(
+                       'options' => 'success',
+                       'warnings' => array(
+                               'options' => array(
+                                       '*' => "Validation error for 'special': cannot be set by this module"
+                               )
+                       )
+               ), $response );
+       }
+
        public function testUnknownOption() {
                $this->mUserMock->expects( $this->never() )
                        ->method( 'resetOptions' );