You are here

protected function CaptchaWebTestBase::assertCaptchaPresence in CAPTCHA 8

Assert that there is a CAPTCHA on the form or not.

Parameters

bool $presence: Whether there should be a CAPTCHA or not.

14 calls to CaptchaWebTestBase::assertCaptchaPresence()
CaptchaAdminTest::testUntrustedUserPosting in tests/src/Functional/CaptchaAdminTest.php
Test untrusted user posting.
CaptchaPersistenceTest::setUpPersistence in tests/src/Functional/CaptchaPersistenceTest.php
Set up the persistence and CAPTCHA settings.
CaptchaPersistenceTest::testPersistenceAlways in tests/src/Functional/CaptchaPersistenceTest.php
Test persistence always.
CaptchaPersistenceTest::testPersistenceOnlyOnce in tests/src/Functional/CaptchaPersistenceTest.php
Test Persistence "Only once".
CaptchaPersistenceTest::testPersistencePerFormInstance in tests/src/Functional/CaptchaPersistenceTest.php
Test persistence per form instance.

... See full list

File

tests/src/Functional/CaptchaWebTestBase.php, line 140

Class

CaptchaWebTestBase
Base class for CAPTCHA tests.

Namespace

Drupal\Tests\captcha\Functional

Code

protected function assertCaptchaPresence($presence) {
  if ($presence) {
    $this
      ->assertSession()
      ->pageTextContains(_captcha_get_description(), 'There should be a CAPTCHA on the form.', 'CAPTCHA');
  }
  else {
    $this
      ->assertSession()
      ->pageTextNotContains(_captcha_get_description(), 'There should be no CAPTCHA on the form.', 'CAPTCHA');
  }
}