ReCaptchaActionListBuilderTest.php in reCAPTCHA v3 8
File
tests/src/Functional/ReCaptchaActionListBuilderTest.php
View source
<?php
namespace Drupal\Tests\recaptcha_v3\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class ReCaptchaActionListBuilderTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'captcha',
'recaptcha_v3',
];
public function testListBuilder() {
$add_form = Url::fromRoute('entity.recaptcha_v3_action.add_form');
$collection = Url::fromRoute('entity.recaptcha_v3_action.collection');
$assert = $this
->assertSession();
$this
->drupalGet($add_form);
$assert
->statusCodeEquals(403);
$this
->drupalGet($collection);
$assert
->statusCodeEquals(403);
$this
->drupalLogIn($this
->createUser([
'administer CAPTCHA settings',
]));
$this
->drupalPostForm($add_form, [
'label' => 'Test action',
'id' => 'test_action',
'threshold' => '.5',
'challenge' => 'default',
], 'Save');
$this
->drupalGet($collection);
$assert
->pageTextContains('Test action');
$assert
->pageTextContains('test_action');
$assert
->pageTextContains('.5');
$assert
->pageTextContains('Default');
}
}