(bug 34302) Add CSS classes to email fields in user preferences
[lhc/web/wiklou.git] / tests / phpunit / includes / PreferencesTest.php
1 <?php
2
3 class PreferencesTest extends MediaWikiTestCase {
4
5 /** Array of User objects */
6 private $users ;
7 private $context ;
8
9 function __construct() {
10 parent::__construct();
11
12 $this->users['noemail'] = new User;
13
14 $this->users['notauth'] = new User;
15 $this->users['notauth']
16 ->setEmail( 'noauth@example.org' );
17
18 $this->users['auth'] = new User;
19 $this->users['auth']
20 ->setEmail( 'noauth@example.org' );
21 $this->users['auth']
22 ->setEmailAuthenticationTimestamp( 1330946623 );
23
24 $this->context = new RequestContext;
25 $this->context->setTitle( Title::newFromText('PreferencesTest') );
26 }
27
28 /**
29 * Placeholder to verify bug 34302
30 * @covers Preferences::profilePreferences
31 */
32 function testEmailFieldsWhenUserHasNoEmail() {
33 $prefs = $this->prefsFor( 'noemail' );
34 $this->assertArrayHasKey( 'cssclass',
35 $prefs['emailaddress']
36 );
37 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
38 }
39 /**
40 * Placeholder to verify bug 34302
41 * @covers Preferences::profilePreferences
42 */
43 function testEmailFieldsWhenUserEmailNotAuthenticated() {
44 $prefs = $this->prefsFor( 'notauth' );
45 $this->assertArrayHasKey( 'cssclass',
46 $prefs['emailaddress']
47 );
48 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
49 }
50 /**
51 * Placeholder to verify bug 34302
52 * @covers Preferences::profilePreferences
53 */
54 function testEmailFieldsWhenUserEmailIsAuthenticated() {
55 $prefs = $this->prefsFor( 'auth' );
56 $this->assertArrayHasKey( 'cssclass',
57 $prefs['emailaddress']
58 );
59 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
60 }
61
62
63 /** Helper */
64 function prefsFor( $user_key ) {
65 $preferences = array();
66 Preferences::profilePreferences(
67 $this->users[$user_key]
68 , $this->context
69 , $preferences
70 );
71 return $preferences;
72 }
73
74 }