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