MediaWiki  1.23.8
PreferencesTest.php
Go to the documentation of this file.
1 <?php
2 
10  private $prefUsers;
14  private $context;
15 
16  public function __construct() {
17  parent::__construct();
18 
19  $this->prefUsers['noemail'] = new User;
20 
21  $this->prefUsers['notauth'] = new User;
22  $this->prefUsers['notauth']
23  ->setEmail( 'noauth@example.org' );
24 
25  $this->prefUsers['auth'] = new User;
26  $this->prefUsers['auth']
27  ->setEmail( 'noauth@example.org' );
28  $this->prefUsers['auth']
29  ->setEmailAuthenticationTimestamp( 1330946623 );
30 
31  $this->context = new RequestContext;
32  $this->context->setTitle( Title::newFromText( 'PreferencesTest' ) );
33  }
34 
35  protected function setUp() {
36  parent::setUp();
37 
38  $this->setMwGlobals( array(
39  'wgEnableEmail' => true,
40  'wgEmailAuthentication' => true,
41  ) );
42  }
43 
48  public function testEmailFieldsWhenUserHasNoEmail() {
49  $prefs = $this->prefsFor( 'noemail' );
50  $this->assertArrayHasKey( 'cssclass',
51  $prefs['emailaddress']
52  );
53  $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
54  }
55 
61  $prefs = $this->prefsFor( 'notauth' );
62  $this->assertArrayHasKey( 'cssclass',
63  $prefs['emailaddress']
64  );
65  $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
66  }
67 
73  $prefs = $this->prefsFor( 'auth' );
74  $this->assertArrayHasKey( 'cssclass',
75  $prefs['emailaddress']
76  );
77  $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
78  }
79 
81  protected function prefsFor( $user_key ) {
82  $preferences = array();
84  $this->prefUsers[$user_key],
85  $this->context,
86  $preferences
87  );
88 
89  return $preferences;
90  }
91 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
PreferencesTest\setUp
setUp()
Definition: PreferencesTest.php:33
PreferencesTest\$prefUsers
User[] $prefUsers
Definition: PreferencesTest.php:9
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PreferencesTest
@group Database
Definition: PreferencesTest.php:6
RequestContext\setTitle
setTitle( $t)
Set the Title object.
Definition: RequestContext.php:116
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
PreferencesTest\testEmailFieldsWhenUserEmailNotAuthenticated
testEmailFieldsWhenUserEmailNotAuthenticated()
Placeholder to verify bug 34302 @covers Preferences::profilePreferences.
Definition: PreferencesTest.php:58
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:30
PreferencesTest\__construct
__construct()
Definition: PreferencesTest.php:14
PreferencesTest\prefsFor
prefsFor( $user_key)
Helper.
Definition: PreferencesTest.php:79
Preferences\profilePreferences
static profilePreferences( $user, IContextSource $context, &$defaultPreferences)
Definition: Preferences.php:194
PreferencesTest\testEmailFieldsWhenUserHasNoEmail
testEmailFieldsWhenUserHasNoEmail()
Placeholder to verify bug 34302 @covers Preferences::profilePreferences.
Definition: PreferencesTest.php:46
User
User
Definition: All_system_messages.txt:425
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
PreferencesTest\testEmailFieldsWhenUserEmailIsAuthenticated
testEmailFieldsWhenUserEmailIsAuthenticated()
Placeholder to verify bug 34302 @covers Preferences::profilePreferences.
Definition: PreferencesTest.php:70
PreferencesTest\$context
RequestContext $context
Definition: PreferencesTest.php:12