From 0e005bbca71f0f78d54850f08d11767a9d8aec09 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 26 Jun 2017 13:11:02 +0100 Subject: [PATCH] Issue #2212869 by hellboy2k8, leevingo, naveenvalecha, Grimreaper, subhojit777, poojasharmaece, kellyimagined, ZeiP, kostyashupenko, andypost, jibran: Extend ContactAuthenticatedUserTest for anonymous user --- .../ContactAuthenticatedUserTest.php | 35 ------------------- .../src/Functional/ContactSitewideTest.php | 21 +++++++++++ 2 files changed, 21 insertions(+), 35 deletions(-) delete mode 100644 core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php diff --git a/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php b/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php deleted file mode 100644 index 43cf3ce0fbb..00000000000 --- a/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php +++ /dev/null @@ -1,35 +0,0 @@ -drupalLogin($this->drupalCreateUser(['access site-wide contact form'])); - $this->drupalGet('contact'); - - // Ensure that there is no textfield for name. - $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name'])); - - // Ensure that there is no textfield for email. - $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail'])); - } - -} diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php index 5b974053673..178a3ad01d2 100644 --- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -44,6 +44,27 @@ class ContactSitewideTest extends BrowserTestBase { * Tests configuration options and the site-wide contact form. */ public function testSiteWideContact() { + // Tests name and email fields for authenticated and anonymous users. + $this->drupalLogin($this->drupalCreateUser(['access site-wide contact form'])); + $this->drupalGet('contact'); + + // Ensure that there is no textfield for name. + $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name'])); + + // Ensure that there is no textfield for email. + $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail'])); + + // Logout and retrieve the page as an anonymous user + $this->drupalLogout(); + user_role_grant_permissions('anonymous', ['access site-wide contact form']); + $this->drupalGet('contact'); + + // Ensure that there is textfield for name. + $this->assertTrue($this->xpath('//input[@name=:name]', [':name' => 'name'])); + + // Ensure that there is textfield for email. + $this->assertTrue($this->xpath('//input[@name=:name]', [':name' => 'mail'])); + // Create and log in administrative user. $admin_user = $this->drupalCreateUser([ 'access site-wide contact form',