Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / contact / tests / src / Functional / ContactSitewideTest.php
index 5b974053673b3b6c619b14f9b2759f46a58670b6..178a3ad01d24d02a5c823a72f59809af60caf540 100644 (file)
@@ -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',