// Check to see that anonymous user cannot see contact page without permission.
user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID,
['access site-wide contact form'
]);
$this->
drupalGet('contact'
);
$this->
assertSession()->
statusCodeEquals(403
);
// Give anonymous user permission and see that page is viewable.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID,
['access site-wide contact form'
]);
$this->
drupalGet('contact'
);
$this->
assertSession()->
statusCodeEquals(200
);
// Submit contact form with invalid values.
$this->
submitContact('',
$recipients[0
],
$this->
randomMachineName(16
),
$id,
$this->
randomMachineName(64
));
$this->
assertSession()->
pageTextContains('Your name field is required.'
);
$this->
submitContact($this->
randomMachineName(16
), '',
$this->
randomMachineName(16
),
$id,
$this->
randomMachineName(64
));
$this->
assertSession()->
pageTextContains('Your email address field is required.'
);
$this->
submitContact($this->
randomMachineName(16
),
$invalid_recipients[0
],
$this->
randomMachineName(16
),
$id,
$this->
randomMachineName(64
));
$this->
assertSession()->
pageTextContains('The email address invalid is not valid.'
);
$this->
submitContact($this->
randomMachineName(16
),
$recipients[0
], '',
$id,
$this->
randomMachineName(64
));
$this->
assertSession()->
pageTextContains('Subject field is required.'
);