6 class PreferencesTest
extends MediaWikiTestCase
{
7 /** Array of User objects */
11 function __construct() {
12 parent
::__construct();
14 $this->prefUsers
['noemail'] = new User
;
16 $this->prefUsers
['notauth'] = new User
;
17 $this->prefUsers
['notauth']
18 ->setEmail( 'noauth@example.org' );
20 $this->prefUsers
['auth'] = new User
;
21 $this->prefUsers
['auth']
22 ->setEmail( 'noauth@example.org' );
23 $this->prefUsers
['auth']
24 ->setEmailAuthenticationTimestamp( 1330946623 );
26 $this->context
= new RequestContext
;
27 $this->context
->setTitle( Title
::newFromText( 'PreferencesTest' ) );
30 protected function setUp() {
33 $this->setMwGlobals( array(
34 'wgEnableEmail' => true,
35 'wgEmailAuthentication' => true,
40 * Placeholder to verify bug 34302
41 * @covers Preferences::profilePreferences
43 function testEmailFieldsWhenUserHasNoEmail() {
44 $prefs = $this->prefsFor( 'noemail' );
45 $this->assertArrayHasKey( 'cssclass',
46 $prefs['emailaddress']
48 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
52 * Placeholder to verify bug 34302
53 * @covers Preferences::profilePreferences
55 function testEmailFieldsWhenUserEmailNotAuthenticated() {
56 $prefs = $this->prefsFor( 'notauth' );
57 $this->assertArrayHasKey( 'cssclass',
58 $prefs['emailaddress']
60 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
64 * Placeholder to verify bug 34302
65 * @covers Preferences::profilePreferences
67 function testEmailFieldsWhenUserEmailIsAuthenticated() {
68 $prefs = $this->prefsFor( 'auth' );
69 $this->assertArrayHasKey( 'cssclass',
70 $prefs['emailaddress']
72 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
76 function prefsFor( $user_key ) {
77 $preferences = array();
78 Preferences
::profilePreferences(
79 $this->prefUsers
[$user_key]