6use Wikimedia\ObjectFactory;
7use Wikimedia\TestingAccessWrapper;
43 $this->context->setTitle( Title::newFromText( self::class ) );
47 $this->config = MediaWikiServices::getInstance()->getMainConfig();
58 AuthManager::singleton(),
59 MediaWikiServices::getInstance()->getLinkRenderer()
69 $this->assertInstanceOf( PreferencesForm::class, $form );
70 $this->assertCount( 5, $form->getPreferenceSections() );
81 $this->assertArrayHasKey(
'cssclass', $prefs[
'emailauthentication'] );
82 $this->assertEquals( $cssClass, $prefs[
'emailauthentication'][
'cssclass'] );
86 $userNoEmail =
new User;
87 $userEmailUnauthed =
new User;
88 $userEmailUnauthed->
setEmail(
'noauth@example.org' );
89 $userEmailAuthed =
new User;
90 $userEmailAuthed->
setEmail(
'noauth@example.org' );
91 $userEmailAuthed->setEmailAuthenticationTimestamp(
wfTimestamp() );
93 [ $userNoEmail,
'mw-email-none' ],
94 [ $userEmailUnauthed,
'mw-email-not-authenticated' ],
95 [ $userEmailAuthed,
'mw-email-authenticated' ],
120 $form = $this->getMockBuilder( PreferencesForm::class )
121 ->disableOriginalConstructor()
124 $userMock = $this->getMockBuilder( User::class )
125 ->disableOriginalConstructor()
127 $userMock->method(
'getOptions' )
128 ->willReturn( $oldOptions );
129 $userMock->method(
'isAllowedAny' )
130 ->willReturn(
true );
131 $userMock->method(
'isAllowed' )
132 ->willReturn(
true );
134 $userMock->expects( $this->exactly( 2 ) )
135 ->method(
'setOption' )
137 [ $this->equalTo(
'test' ), $this->equalTo( $newOptions[
'test' ] ) ],
138 [ $this->equalTo(
'option' ), $this->equalTo( $newOptions[
'option' ] ) ]
141 $form->expects( $this->
any() )
142 ->method(
'getModifiedUser' )
143 ->willReturn( $userMock );
145 $form->expects( $this->
any() )
146 ->method(
'getContext' )
147 ->willReturn( $this->context );
149 $form->expects( $this->
any() )
150 ->method(
'getConfig' )
151 ->willReturn( $configMock );
154 function ( $formData, $form, $user, &$result, $oldUserOptions )
155 use ( $newOptions, $oldOptions, $userMock ) {
156 $this->assertSame( $userMock, $user );
157 foreach ( $newOptions as $option =>
$value ) {
158 $this->assertSame(
$value, $formData[ $option ] );
160 foreach ( $oldOptions as $option =>
$value ) {
161 $this->assertSame(
$value, $oldUserOptions[ $option ] );
163 $this->assertEquals(
true, $result );
168 $factory->saveFormData( $newOptions, $form );
176 $this->context->getRequest()->setVal(
'wprclimit',
' 0012 ' );
181 $this->assertEquals( 12, $user->getOption(
'rclimit' ) );
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
$wgParserConf
Parser configuration.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
testGetForm()
MediaWiki\Preferences\DefaultPreferencesFactory::getForm()
testPreferencesFormPreSaveHookHasCorrectData()
Test that PreferencesFormPreSave hook has correct data:
emailAuthenticationProvider()
getPreferencesFactory()
Get a basic PreferencesFactory for testing with.
testEmailAuthentication( $user, $cssClass)
CSS classes for emailauthentication preference field when there's no email.
testIntvalFilter()
The rclimit preference should accept non-integer input and filter it to become an integer.
A Config instance which stores all settings as a member variable.
Internationalisation code.
Group all the pieces relevant to the context of a request into one instance.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
setEmail( $str)
Set the user's e-mail address.
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.