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