public function VarnishPurgerFormTestBase::testFormSubmit in Varnish purger 8.2
Same name and namespace in other branches
- 8 src/Tests/VarnishPurgerFormTestBase.php \Drupal\varnish_purger\Tests\VarnishPurgerFormTestBase::testFormSubmit()
Test posting data to the HTTP Purger settings form.
File
- src/
Tests/ VarnishPurgerFormTestBase.php, line 118
Class
- VarnishPurgerFormTestBase
- Testbase for testing \Drupal\varnish_purger\Form\VarnishPurgerFormBase.
Namespace
Drupal\varnish_purger\TestsCode
public function testFormSubmit() {
// Assert that all (simple) fields submit as intended.
$this
->drupalLogin($this->admin_user);
$edit = [
'name' => 'foobar',
'invalidationtype' => 'wildcardurl',
'hostname' => 'example.com',
'port' => 8080,
'path' => 'node/1',
'request_method' => 1,
'scheme' => 0,
'verify' => TRUE,
'timeout' => 6,
'runtime_measurement' => 1,
'connect_timeout' => 0.5,
'cooldown_time' => 0.8,
'max_requests' => 25,
'http_errors' => 1,
];
$this
->drupalPostForm($this->route, $edit, t('Save configuration'));
$this
->drupalGet($this->route);
foreach ($edit as $field => $value) {
$this
->assertFieldById('edit-' . str_replace('_', '-', $field), $value);
}
// Assert headers behavior.
$form = $this
->getFormInstance();
$form_state = $this
->getFormStateInstance();
$form_state
->addBuildInfo('args', [
$this->formArgs,
]);
$form_state
->setValue('headers', [
[
'field' => 'foo',
'value' => 'bar',
],
]);
$this->formBuilder
->submitForm($form, $form_state);
$this
->assertEquals(0, count($form_state
->getErrors()));
$this
->drupalGet($this->route);
$this
->assertFieldById('edit-headers-0-field', 'foo');
$this
->assertFieldById('edit-headers-0-value', 'bar');
}