Skip to content
Snippets Groups Projects
Commit 731acab7 authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-4881-lkmorlan-test-anti-spam' into '3.0.x'

ISTWCMS-4881: Test Webform anti-spam

See merge request !165
parents 50b6611a 793cfa3c
No related branches found
No related tags found
2 merge requests!433ISTWCMS-6296 Create test for all event dates test cases,!165ISTWCMS-4881: Test Webform anti-spam
...@@ -249,6 +249,9 @@ class UwWcmsBasicTest extends BrowserTestBase { ...@@ -249,6 +249,9 @@ class UwWcmsBasicTest extends BrowserTestBase {
]; ];
$this->drupalPostForm('admin/structure/webform/add', $edit, 'Save'); $this->drupalPostForm('admin/structure/webform/add', $edit, 'Save');
// Test for existence Webform CAPTCHA component on newly-created Webform.
$this->assertFieldByXPath('//table[@id="edit-webform-ui-elements"]/tbody/tr[@data-webform-type="captcha"]', NULL, 'CAPTCHA component exists.');
// The variable $test_paths stores Drupal paths and permission information. // The variable $test_paths stores Drupal paths and permission information.
// In this array, the keys are paths. If the value is TRUE, everyone has // In this array, the keys are paths. If the value is TRUE, everyone has
// access. Otherwise, the value must be an array of roles that have access. // access. Otherwise, the value must be an array of roles that have access.
...@@ -313,6 +316,13 @@ class UwWcmsBasicTest extends BrowserTestBase { ...@@ -313,6 +316,13 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this_code = $this->getSession()->getStatusCode(); $this_code = $this->getSession()->getStatusCode();
$message = sprintf('Response status code for %s on path %s is %d; %d expected.', $role, $path, $this_code, $expected_code); $message = sprintf('Response status code for %s on path %s is %d; %d expected.', $role, $path, $this_code, $expected_code);
$this->assert(intval($this_code) === $expected_code, $message); $this->assert(intval($this_code) === $expected_code, $message);
if ($path === 'form/test-form' && !$this->loggedInUser) {
// Test for Honeypot element.
$this->assertRaw('Leave this field blank');
// Test for hCaptcha element.
$this->assertFieldByXPath('//div[@class="captcha"]/input[@name="captcha_token"]', NULL, 'Page has hCaptcha element.');
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment