diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactAuthenticatedUserTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactAuthenticatedUserTest.php new file mode 100644 index 0000000..672f0f5 --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactAuthenticatedUserTest.php @@ -0,0 +1,44 @@ + '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'))); + } +} \ No newline at end of file diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 6136133..80d4dec 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -180,6 +180,10 @@ class ContactSitewideTest 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);