HoneypotFormProgrammaticSubmissionTest.php in Honeypot 2.0.x
File
tests/src/Functional/HoneypotFormProgrammaticSubmissionTest.php
View source
<?php
namespace Drupal\Tests\honeypot\Functional;
use Drupal\Component\Serialization\Json;
use Drupal\Tests\BrowserTestBase;
class HoneypotFormProgrammaticSubmissionTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'honeypot',
'honeypot_test',
'user',
];
protected function setUp() {
parent::setUp();
$honeypot_config = \Drupal::configFactory()
->getEditable('honeypot.settings');
$honeypot_config
->set('element_name', 'url');
$honeypot_config
->set('time_limit', 5);
$honeypot_config
->set('protect_all_forms', TRUE);
$honeypot_config
->set('log', FALSE);
$honeypot_config
->save();
$this
->drupalCreateUser([], 'robo-user');
}
public function testProgrammaticFormSubmission() {
$result = $this
->drupalGet('/honeypot_test/submit_form');
$form_errors = (array) Json::decode($result);
$this
->assertSession()
->responseNotContains('There was a problem with your form submission. Please wait 6 seconds and try again.');
$this
->assertEmpty($form_errors, 'The were no validation errors when submitting the form.');
}
}