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