place holder to test bug 34919 when it is fixed
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 5 Mar 2012 11:48:35 +0000 (11:48 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 5 Mar 2012 11:48:35 +0000 (11:48 +0000)
tests/phpunit/includes/PreferencesTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/PreferencesTest.php b/tests/phpunit/includes/PreferencesTest.php
new file mode 100644 (file)
index 0000000..47aaf3d
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+
+class PreferencesTest extends MediaWikiTestCase {
+
+       /** Array of User objects */
+       private $users ;
+       private $context ;
+
+       function __construct() {
+               parent::__construct();
+
+               $this->users['noemail'] = new User;
+
+               $this->users['notauth'] = new User;
+               $this->users['notauth']
+                       ->setEmail( 'noauth@example.org' );
+
+               $this->users['auth']    = new User;
+               $this->users['auth']
+                       ->setEmail( 'noauth@example.org' );
+               $this->users['auth']
+                       ->setEmailAuthenticationTimestamp( 1330946623 );
+
+               $this->context = new RequestContext;
+               $this->context->setTitle( Title::newFromText('PreferencesTest') );
+       }
+
+       /**
+        * Placeholder to verify bug 34919
+        * @covers Preferences::profilePreferences
+        */
+       function testEmailFieldsWhenUserHasNoEmail() {
+               $prefs = $this->prefsFor( 'noemail' );
+               $this->assertArrayNotHasKey( 'class',
+                       $prefs['emailaddress']
+               );
+       }
+       /**
+        * Placeholder to verify bug 34919
+        * @covers Preferences::profilePreferences
+        */
+       function testEmailFieldsWhenUserEmailNotAuthenticated() {
+               $prefs = $this->prefsFor( 'notauth' );
+               $this->assertArrayNotHasKey( 'class',
+                       $prefs['emailaddress']
+               );
+       }
+       /**
+        * Placeholder to verify bug 34919
+        * @covers Preferences::profilePreferences
+        */
+       function testEmailFieldsWhenUserEmailIsAuthenticated() {
+               $prefs = $this->prefsFor( 'auth' );
+               $this->assertArrayNotHasKey( 'class',
+                       $prefs['emailaddress']
+               );
+       }
+
+
+       /** Helper */
+       function prefsFor( $user_key ) {
+               $preferences = array();
+               Preferences::profilePreferences(
+                       $this->users[$user_key]
+                       , $this->context
+                       , $preferences
+               );
+               return $preferences;
+       }
+
+}