You are here

protected function HoneypotFormCacheTest::setUp in Honeypot 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/HoneypotFormCacheTest.php \Drupal\Tests\honeypot\Functional\HoneypotFormCacheTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/HoneypotFormCacheTest.php, line 46

Class

HoneypotFormCacheTest
Tests page caching on Honeypot protected forms.

Namespace

Drupal\Tests\honeypot\Functional

Code

protected function setUp() {
  parent::setUp();

  // Set up required Honeypot configuration.
  $honeypot_config = \Drupal::configFactory()
    ->getEditable('honeypot.settings');
  $honeypot_config
    ->set('element_name', 'url');

  // Enable time_limit protection.
  $honeypot_config
    ->set('time_limit', 5);

  // Test protecting all forms.
  $honeypot_config
    ->set('protect_all_forms', TRUE);
  $honeypot_config
    ->set('log', FALSE);
  $honeypot_config
    ->save();

  // Set up other required configuration.
  $user_config = \Drupal::configFactory()
    ->getEditable('user.settings');
  $user_config
    ->set('verify_mail', TRUE);
  $user_config
    ->set('register', UserInterface::REGISTER_VISITORS);
  $user_config
    ->save();

  // Create an Article node type.
  if ($this->profile != 'standard') {
    $this
      ->drupalCreateContentType([
      'type' => 'article',
      'name' => 'Article',
    ]);

    // Create comment field on article.
    $this
      ->addDefaultCommentField('node', 'article');
  }
}