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