summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2015-05-28 22:19:51 (GMT)
committerhass2015-05-28 22:19:51 (GMT)
commit680ed48069d1e72279ab3c776f24703d3de15baf (patch)
tree1760e74983ef18613c2404a79711ebda729c0bbe
parentb0473252f03bc2225ef4362003a4e2ea7620d0a8 (diff)
Issue #2496741 by hass: Tests
-rw-r--r--src/Tests/ReCaptchaBasicTest.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Tests/ReCaptchaBasicTest.php b/src/Tests/ReCaptchaBasicTest.php
index 78ecaab..31706aa 100644
--- a/src/Tests/ReCaptchaBasicTest.php
+++ b/src/Tests/ReCaptchaBasicTest.php
@@ -145,6 +145,28 @@ class ReCaptchaBasicTest extends WebTestBase {
$this->assertRaw($grecaptcha . "\n" . '<noscript>', '[testReCaptchaOnLoginForm]: NoScript for reCAPTCHA is shown on form.');
$this->assertRaw('https://www.google.com/recaptcha/api/fallback?k=' . $site_key . '&amp;hl=' . \Drupal::service('language_manager')->getCurrentLanguage()->getId(), '[testReCaptchaOnLoginForm]: Fallback URL with IFRAME has been found.');
+ // Check that data-size attribute does not exists.
+ $this->config('recaptcha.settings')->set('widget.size', '')->save();
+ $element = $this->xpath('//div[@class=:class and @data-size=:size]', [':class' => 'g-recaptcha', ':size' => 'small']);
+ $this->assertFalse(!empty($element), 'Tag contains no data-size attribute.');
+
+ // Check that data-size attribute exists.
+ $this->config('recaptcha.settings')->set('widget.size', 'small')->save();
+ $this->drupalGet('user/login');
+ $element = $this->xpath('//div[@class=:class and @data-size=:size]', [':class' => 'g-recaptcha', ':size' => 'small']);
+ $this->assertTrue(!empty($element), 'Tag contains data-size attribute and value.');
+
+ // Check that data-tabindex attribute does not exists.
+ $this->config('recaptcha.settings')->set('widget.tabindex', 0)->save();
+ $element = $this->xpath('//div[@class=:class and @data-tabindex=:index]', [':class' => 'g-recaptcha', ':index' => 0]);
+ $this->assertFalse(!empty($element), 'Tag contains no data-tabindex attribute.');
+
+ // Check that data-tabindex attribute exists.
+ $this->config('recaptcha.settings')->set('widget.tabindex', 5)->save();
+ $this->drupalGet('user/login');
+ $element = $this->xpath('//div[@class=:class and @data-tabindex=:index]', [':class' => 'g-recaptcha', ':index' => 5]);
+ $this->assertTrue(!empty($element), 'Tag contains data-tabindex attribute and value.');
+
// Try to log in, which should fail.
$edit['name'] = $this->normal_user->getUsername();
$edit['pass'] = $this->normal_user->getPassword();