6 class PreferencesTest
extends MediaWikiTestCase
{
16 public function __construct() {
17 parent
::__construct();
19 $this->prefUsers
['noemail'] = new User
;
21 $this->prefUsers
['notauth'] = new User
;
22 $this->prefUsers
['notauth']
23 ->setEmail( 'noauth@example.org' );
25 $this->prefUsers
['auth'] = new User
;
26 $this->prefUsers
['auth']
27 ->setEmail( 'noauth@example.org' );
28 $this->prefUsers
['auth']
29 ->setEmailAuthenticationTimestamp( 1330946623 );
31 $this->context
= new RequestContext
;
32 $this->context
->setTitle( Title
::newFromText( 'PreferencesTest' ) );
35 protected function setUp() {
38 $this->setMwGlobals( [
39 'wgEnableEmail' => true,
40 'wgEmailAuthentication' => true,
45 * Placeholder to verify T36302
46 * @covers Preferences::profilePreferences
47 * @deprecated replaced by DefaultPreferencesFactoryTest::testEmailAuthentication()
49 public function testEmailAuthenticationFieldWhenUserHasNoEmail() {
50 $prefs = $this->prefsFor( 'noemail' );
51 $this->assertArrayHasKey( 'cssclass',
52 $prefs['emailauthentication']
54 $this->assertEquals( 'mw-email-none', $prefs['emailauthentication']['cssclass'] );
58 * Placeholder to verify T36302
59 * @covers Preferences::profilePreferences
60 * @deprecated replaced by DefaultPreferencesFactoryTest::testEmailAuthentication()
62 public function testEmailAuthenticationFieldWhenUserEmailNotAuthenticated() {
63 $prefs = $this->prefsFor( 'notauth' );
64 $this->assertArrayHasKey( 'cssclass',
65 $prefs['emailauthentication']
67 $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailauthentication']['cssclass'] );
71 * Placeholder to verify T36302
72 * @covers Preferences::profilePreferences
73 * @deprecated replaced by DefaultPreferencesFactoryTest::testEmailAuthentication()
75 public function testEmailAuthenticationFieldWhenUserEmailIsAuthenticated() {
76 $prefs = $this->prefsFor( 'auth' );
77 $this->assertArrayHasKey( 'cssclass',
78 $prefs['emailauthentication']
80 $this->assertEquals( 'mw-email-authenticated', $prefs['emailauthentication']['cssclass'] );
84 protected function prefsFor( $user_key ) {
85 return Preferences
::getPreferences(
86 $this->prefUsers
[$user_key],