MediaWiki
REL1_31
PreferencesTest.php
Go to the documentation of this file.
1
<?php
2
6
class
PreferencesTest
extends
MediaWikiTestCase
{
10
private
$prefUsers
;
14
private
$context
;
15
16
public
function
__construct
() {
17
parent::__construct();
18
19
$this->prefUsers[
'noemail'
] =
new
User
;
20
21
$this->prefUsers[
'notauth'
] =
new
User
;
22
$this->prefUsers[
'notauth'
]
23
->
setEmail
(
'noauth@example.org'
);
24
25
$this->prefUsers[
'auth'
] =
new
User
;
26
$this->prefUsers[
'auth'
]
27
->
setEmail
(
'noauth@example.org'
);
28
$this->prefUsers[
'auth'
]
29
->setEmailAuthenticationTimestamp( 1330946623 );
30
31
$this->context =
new
RequestContext
;
32
$this->context->
setTitle
( Title::newFromText(
'PreferencesTest'
) );
33
}
34
35
protected
function
setUp
() {
36
parent::setUp();
37
38
$this->
setMwGlobals
( [
39
'wgEnableEmail'
=>
true
,
40
'wgEmailAuthentication'
=>
true
,
41
] );
42
}
43
49
public
function
testEmailAuthenticationFieldWhenUserHasNoEmail
() {
50
$prefs = $this->
prefsFor
(
'noemail'
);
51
$this->assertArrayHasKey(
'cssclass'
,
52
$prefs[
'emailauthentication'
]
53
);
54
$this->assertEquals(
'mw-email-none'
, $prefs[
'emailauthentication'
][
'cssclass'
] );
55
}
56
62
public
function
testEmailAuthenticationFieldWhenUserEmailNotAuthenticated
() {
63
$prefs = $this->
prefsFor
(
'notauth'
);
64
$this->assertArrayHasKey(
'cssclass'
,
65
$prefs[
'emailauthentication'
]
66
);
67
$this->assertEquals(
'mw-email-not-authenticated'
, $prefs[
'emailauthentication'
][
'cssclass'
] );
68
}
69
75
public
function
testEmailAuthenticationFieldWhenUserEmailIsAuthenticated
() {
76
$prefs = $this->
prefsFor
(
'auth'
);
77
$this->assertArrayHasKey(
'cssclass'
,
78
$prefs[
'emailauthentication'
]
79
);
80
$this->assertEquals(
'mw-email-authenticated'
, $prefs[
'emailauthentication'
][
'cssclass'
] );
81
}
82
84
protected
function
prefsFor
( $user_key ) {
85
return
Preferences::getPreferences
(
86
$this->prefUsers[$user_key],
87
$this->context
88
);
89
}
90
}
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition
MediaWikiTestCase.php:678
PreferencesTest
Database.
Definition
PreferencesTest.php:6
PreferencesTest\$context
RequestContext $context
Definition
PreferencesTest.php:14
PreferencesTest\__construct
__construct()
Definition
PreferencesTest.php:16
PreferencesTest\prefsFor
prefsFor( $user_key)
Helper.
Definition
PreferencesTest.php:84
PreferencesTest\setUp
setUp()
Definition
PreferencesTest.php:35
PreferencesTest\testEmailAuthenticationFieldWhenUserEmailNotAuthenticated
testEmailAuthenticationFieldWhenUserEmailNotAuthenticated()
Placeholder to verify T36302 Preferences::profilePreferences.
Definition
PreferencesTest.php:62
PreferencesTest\testEmailAuthenticationFieldWhenUserEmailIsAuthenticated
testEmailAuthenticationFieldWhenUserEmailIsAuthenticated()
Placeholder to verify T36302 Preferences::profilePreferences.
Definition
PreferencesTest.php:75
PreferencesTest\testEmailAuthenticationFieldWhenUserHasNoEmail
testEmailAuthenticationFieldWhenUserHasNoEmail()
Placeholder to verify T36302 Preferences::profilePreferences.
Definition
PreferencesTest.php:49
PreferencesTest\$prefUsers
User[] $prefUsers
Definition
PreferencesTest.php:10
Preferences\getPreferences
static getPreferences( $user, IContextSource $context)
Definition
Preferences.php:61
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:32
RequestContext\setTitle
setTitle(Title $title=null)
Definition
RequestContext.php:151
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition
User.php:53
User\setEmail
setEmail( $str)
Set the user's e-mail address.
Definition
User.php:3055
tests
phpunit
includes
PreferencesTest.php
Generated on Mon Nov 25 2024 15:36:31 for MediaWiki by
1.10.0