diff --git a/core/modules/contact/contact.test b/core/modules/contact/contact.test index c80f21d..c903bbf 100644 --- a/core/modules/contact/contact.test +++ b/core/modules/contact/contact.test @@ -177,6 +177,10 @@ class ContactSitewideTestCase extends WebTestBase { $this->addCategory('bar', 'bar@example.com', $bar_autoreply, FALSE); $this->addCategory('no_autoreply', 'bar@example.com', '', FALSE); + // Log the current user out in order to test the name and email fields. + $this->drupalLogout(); + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); + // Test the auto-reply for category 'foo'. $email = $this->randomName(32) . '@example.com'; $subject = $this->randomName(64); @@ -435,3 +439,36 @@ class ContactPersonalTestCase extends WebTestBase { $this->drupalPost('user/' . $account->uid . '/contact', $message, t('Send message')); } } + +/** + * Tests the contact form for authenticated users. + */ +class ContactAuthenticatedTestCase extends WebTestBase { + + public static function getInfo() { + return array( + 'name' => 'Contact form textfields.', + 'description' => 'Tests contact form textfields are present if authenticated', + 'group' => 'Contact', + ); + } + + function setUp() { + parent::setUp('contact'); + } + + /** + * Tests that name and email fields are not present for authenticated users. + */ + function testContactSiteWideTextfieldsLoggedInTestCase() { + $user = $this->drupalCreateUser(array('access site-wide contact form')); + $this->drupalLogin($user); + $this->drupalGet('contact'); + + // Ensure that there is no textfield for name. + $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'name'))); + + // Ensure that there is no textfield for email. + $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'mail'))); + } +}