X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiOptionsTest.php;h=5f955bbc4ec2d4e245cd24f668c2b83a27945f9f;hb=0c615d9029cb6e0d65c21f1df5a8a54e197b860a;hp=6659414cb51efe45f032c61f53a220f5a6775a86;hpb=665f171a18061aacd339102a21f32d714c5de50d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiOptionsTest.php b/tests/phpunit/includes/api/ApiOptionsTest.php index 6659414cb5..5f955bbc4e 100644 --- a/tests/phpunit/includes/api/ApiOptionsTest.php +++ b/tests/phpunit/includes/api/ApiOptionsTest.php @@ -17,7 +17,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase { /** @var DerivativeContext */ private $mContext; - private $mOldGetPreferencesHooks = false; + private $mOldGetPreferencesHooks; private static $Success = array( 'options' => 'success' ); @@ -61,10 +61,8 @@ class ApiOptionsTest extends MediaWikiLangTestCase { protected function tearDown() { global $wgHooks; - if ( $this->mOldGetPreferencesHooks !== false ) { - $wgHooks['GetPreferences'] = $this->mOldGetPreferencesHooks; - $this->mOldGetPreferencesHooks = false; - } + $wgHooks['GetPreferences'] = $this->mOldGetPreferencesHooks; + $this->mOldGetPreferencesHooks = false; parent::tearDown(); } @@ -116,6 +114,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase { 'testmultiselect-opt2' => 'registered-multiselect', 'testmultiselect-opt3' => 'registered-multiselect', 'testmultiselect-opt4' => 'registered-multiselect', + 'special' => 'special', ); if ( $options === null ) { @@ -317,7 +316,9 @@ class ApiOptionsTest extends MediaWikiLangTestCase { $this->mUserMock->expects( $this->once() ) ->method( 'saveSettings' ); - $request = $this->getSampleRequest( array( 'change' => 'willBeNull|willBeEmpty=|willBeHappy=Happy' ) ); + $request = $this->getSampleRequest( array( + 'change' => 'willBeNull|willBeEmpty=|willBeHappy=Happy' + ) ); $response = $this->executeQuery( $request ); @@ -381,7 +382,8 @@ class ApiOptionsTest extends MediaWikiLangTestCase { ->method( 'saveSettings' ); $request = $this->getSampleRequest( array( - 'change' => 'testmultiselect-opt1=1|testmultiselect-opt2|testmultiselect-opt3=|testmultiselect-opt4=0' + 'change' => 'testmultiselect-opt1=1|testmultiselect-opt2|' + . 'testmultiselect-opt3=|testmultiselect-opt4=0' ) ); $response = $this->executeQuery( $request ); @@ -389,6 +391,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' );