Merge "[FileBackend] Tweaked TempFSFile::bind() to handle __get()."
[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
11 $this->prefUsers['noemail'] = new User;
12
13 $this->prefUsers['notauth'] = new User;
14 $this->prefUsers['notauth']
15 ->setEmail( 'noauth@example.org' );
16
17 $this->prefUsers['auth'] = new User;
18 $this->prefUsers['auth']
19 ->setEmail( 'noauth@example.org' );
20 $this->prefUsers['auth']
21 ->setEmailAuthenticationTimestamp( 1330946623 );
22
23 $this->context = new RequestContext;
24 $this->context->setTitle( Title::newFromText('PreferencesTest') );
25 }
26
27 protected function setUp() {
28 parent::setUp();
29
30 $this->setMwGlobals( 'wgEnableEmail', true );
31 }
32
33 /**
34 * Placeholder to verify bug 34302
35 * @covers Preferences::profilePreferences
36 */
37 function testEmailFieldsWhenUserHasNoEmail() {
38 $prefs = $this->prefsFor( 'noemail' );
39 $this->assertArrayHasKey( 'cssclass',
40 $prefs['emailaddress']
41 );
42 $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
43 }
44 /**
45 * Placeholder to verify bug 34302
46 * @covers Preferences::profilePreferences
47 */
48 function testEmailFieldsWhenUserEmailNotAuthenticated() {
49 $prefs = $this->prefsFor( 'notauth' );
50 $this->assertArrayHasKey( 'cssclass',
51 $prefs['emailaddress']
52 );
53 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
54 }
55 /**
56 * Placeholder to verify bug 34302
57 * @covers Preferences::profilePreferences
58 */
59 function testEmailFieldsWhenUserEmailIsAuthenticated() {
60 $prefs = $this->prefsFor( 'auth' );
61 $this->assertArrayHasKey( 'cssclass',
62 $prefs['emailaddress']
63 );
64 $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
65 }
66
67 /** Helper */
68 function prefsFor( $user_key ) {
69 $preferences = array();
70 Preferences::profilePreferences(
71 $this->prefUsers[$user_key]
72 , $this->context
73 , $preferences
74 );
75 return $preferences;
76 }
77 }