3 class PreferencesTest
extends MediaWikiTestCase
{
4 /** Array of User objects */
8 function __construct() {
10 global $wgEnableEmail;
12 $this->prefUsers
['noemail'] = new User
;
14 $this->prefUsers
['notauth'] = new User
;
15 $this->prefUsers
['notauth']
16 ->setEmail( 'noauth@example.org' );
18 $this->prefUsers
['auth'] = new User
;
19 $this->prefUsers
['auth']
20 ->setEmail( 'noauth@example.org' );
21 $this->prefUsers
['auth']
22 ->setEmailAuthenticationTimestamp( 1330946623 );
24 $this->context
= new RequestContext
;
25 $this->context
->setTitle( Title
::newFromText('PreferencesTest') );
27 //some tests depends on email setting
28 $wgEnableEmail = true;
32 * Placeholder to verify bug 34302
33 * @covers Preferences::profilePreferences
35 function testEmailFieldsWhenUserHasNoEmail() {
36 $prefs = $this->prefsFor( 'noemail' );
37 $this->assertArrayHasKey( 'cssclass',
38 $prefs['emailaddress']
40 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
43 * Placeholder to verify bug 34302
44 * @covers Preferences::profilePreferences
46 function testEmailFieldsWhenUserEmailNotAuthenticated() {
47 $prefs = $this->prefsFor( 'notauth' );
48 $this->assertArrayHasKey( 'cssclass',
49 $prefs['emailaddress']
51 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
54 * Placeholder to verify bug 34302
55 * @covers Preferences::profilePreferences
57 function testEmailFieldsWhenUserEmailIsAuthenticated() {
58 $prefs = $this->prefsFor( 'auth' );
59 $this->assertArrayHasKey( 'cssclass',
60 $prefs['emailaddress']
62 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
66 function prefsFor( $user_key ) {
67 $preferences = array();
68 Preferences
::profilePreferences(
69 $this->prefUsers
[$user_key]