3 class PreferencesTest
extends MediaWikiTestCase
{
5 /** Array of User objects */
9 function __construct() {
10 parent
::__construct();
11 global $wgEnableEmail;
13 $this->users
['noemail'] = new User
;
15 $this->users
['notauth'] = new User
;
16 $this->users
['notauth']
17 ->setEmail( 'noauth@example.org' );
19 $this->users
['auth'] = new User
;
21 ->setEmail( 'noauth@example.org' );
23 ->setEmailAuthenticationTimestamp( 1330946623 );
25 $this->context
= new RequestContext
;
26 $this->context
->setTitle( Title
::newFromText('PreferencesTest') );
28 //some tests depends on email setting
29 $wgEnableEmail = true;
33 * Placeholder to verify bug 34302
34 * @covers Preferences::profilePreferences
36 function testEmailFieldsWhenUserHasNoEmail() {
37 $prefs = $this->prefsFor( 'noemail' );
38 $this->assertArrayHasKey( 'cssclass',
39 $prefs['emailaddress']
41 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
44 * Placeholder to verify bug 34302
45 * @covers Preferences::profilePreferences
47 function testEmailFieldsWhenUserEmailNotAuthenticated() {
48 $prefs = $this->prefsFor( 'notauth' );
49 $this->assertArrayHasKey( 'cssclass',
50 $prefs['emailaddress']
52 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
55 * Placeholder to verify bug 34302
56 * @covers Preferences::profilePreferences
58 function testEmailFieldsWhenUserEmailIsAuthenticated() {
59 $prefs = $this->prefsFor( 'auth' );
60 $this->assertArrayHasKey( 'cssclass',
61 $prefs['emailaddress']
63 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
68 function prefsFor( $user_key ) {
69 $preferences = array();
70 Preferences
::profilePreferences(
71 $this->users
[$user_key]