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( 'wgEnableEmail', true );
37 * Placeholder to verify bug 34302
38 * @covers Preferences::profilePreferences
40 function testEmailFieldsWhenUserHasNoEmail() {
41 $prefs = $this->prefsFor( 'noemail' );
42 $this->assertArrayHasKey( 'cssclass',
43 $prefs['emailaddress']
45 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
48 * Placeholder to verify bug 34302
49 * @covers Preferences::profilePreferences
51 function testEmailFieldsWhenUserEmailNotAuthenticated() {
52 $prefs = $this->prefsFor( 'notauth' );
53 $this->assertArrayHasKey( 'cssclass',
54 $prefs['emailaddress']
56 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
59 * Placeholder to verify bug 34302
60 * @covers Preferences::profilePreferences
62 function testEmailFieldsWhenUserEmailIsAuthenticated() {
63 $prefs = $this->prefsFor( 'auth' );
64 $this->assertArrayHasKey( 'cssclass',
65 $prefs['emailaddress']
67 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
71 function prefsFor( $user_key ) {
72 $preferences = array();
73 Preferences
::profilePreferences(
74 $this->prefUsers
[$user_key]