/** @var DerivativeContext */
private $mContext;
- private $mOldGetPreferencesHooks = false;
+ private $mOldGetPreferencesHooks;
private static $Success = array( 'options' => 'success' );
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();
}
return true;
}
+ /**
+ * @param IContextSource $context
+ * @param array|null $options
+ *
+ * @return array
+ */
public function getOptionKinds( IContextSource $context, $options = null ) {
// Match with above.
$kinds = array(
'testmultiselect-opt2' => 'registered-multiselect',
'testmultiselect-opt3' => 'registered-multiselect',
'testmultiselect-opt4' => 'registered-multiselect',
+ 'special' => 'special',
);
if ( $options === null ) {
$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 );
->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 );
$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' );