- public function testUserjsOption() {
- $this->mUserMock->expects( $this->never() )
- ->method( 'resetOptions' );
-
- $this->mUserMock->expects( $this->once() )
- ->method( 'setOption' )
- ->with( $this->equalTo( 'userjs-option' ), $this->equalTo( '1' ) );
-
- $this->mUserMock->expects( $this->once() )
- ->method( 'saveSettings' );
-
- $request = $this->getSampleRequest( [
- 'change' => 'userjs-option=1'
- ] );
-
- $response = $this->executeQuery( $request );
-
- $this->assertEquals( self::$Success, $response );
+ public function provideOptionManupulation() {
+ return [
+ [
+ [ 'change' => 'userjs-option=1' ],
+ [ [ 'userjs-option', '1' ] ],
+ null,
+ 'Setting userjs options',
+ ],
+ [
+ [ 'change' => 'willBeNull|willBeEmpty=|willBeHappy=Happy' ],
+ [
+ [ 'willBeNull', null ],
+ [ 'willBeEmpty', '' ],
+ [ 'willBeHappy', 'Happy' ],
+ ],
+ null,
+ 'Basic option setting',
+ ],
+ [
+ [ 'change' => 'testradio=option2' ],
+ [ [ 'testradio', 'option2' ] ],
+ null,
+ 'Changing radio options',
+ ],
+ [
+ [ 'change' => 'testradio' ],
+ [ [ 'testradio', null ] ],
+ null,
+ 'Resetting radio options',
+ ],
+ [
+ [ 'change' => 'unknownOption=1' ],
+ [],
+ [
+ 'options' => 'success',
+ 'warnings' => [
+ 'options' => [
+ 'warnings' => "Validation error for \"unknownOption\": not a valid preference."
+ ],
+ ],
+ ],
+ 'Unrecognized options should be rejected',
+ ],
+ [
+ [ 'change' => 'special=1' ],
+ [],
+ [
+ 'options' => 'success',
+ 'warnings' => [
+ 'options' => [
+ 'warnings' => "Validation error for \"special\": cannot be set by this module."
+ ]
+ ]
+ ],
+ 'Refuse setting special options',
+ ],
+ [
+ [
+ 'change' => 'testmultiselect-opt1=1|testmultiselect-opt2|'
+ . 'testmultiselect-opt3=|testmultiselect-opt4=0'
+ ],
+ [
+ [ 'testmultiselect-opt1', true ],
+ [ 'testmultiselect-opt2', null ],
+ [ 'testmultiselect-opt3', false ],
+ [ 'testmultiselect-opt4', false ],
+ ],
+ null,
+ 'Setting multiselect options',
+ ],
+ [
+ [ 'optionname' => 'name', 'optionvalue' => 'value' ],
+ [ [ 'name', 'value' ] ],
+ null,
+ 'Setting options via optionname/optionvalue'
+ ],
+ [
+ [ 'optionname' => 'name' ],
+ [ [ 'name', null ] ],
+ null,
+ 'Resetting options via optionname without optionvalue',
+ ],
+ ];