PurgerConfigFormTest.php in Purge 8.3
File
tests/modules/purge_purger_test/tests/src/Functional/PurgerConfigFormTest.php
View source
<?php
namespace Drupal\Tests\purge_purger_test\Functional;
use Drupal\purge_purger_test\Form\PurgerConfigForm;
use Drupal\Tests\purge_ui\Functional\Form\Config\PurgerConfigFormTestBase;
class PurgerConfigFormTest extends PurgerConfigFormTestBase {
public static $modules = [
'purge_purger_test',
];
protected $pluginId = 'withform';
protected $formClass = PurgerConfigForm::class;
protected $formId = 'purge_purger_test.purgerconfigform';
public function testFieldExistence() : void {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->fieldExists('edit-textfield');
$this
->assertSession()
->pageTextContains("Test");
}
public function testFormValidation() : void {
$form_state = $this
->getFormStateInstance();
$form_state
->addBuildInfo('args', $this->formArgs);
$form_state
->setValues([
'textfield' => "The moose in the noose ate the goose who was loose.",
]);
$form = $this
->getFormInstance();
$this
->formBuilder()
->submitForm($form, $form_state);
$errors = $form_state
->getErrors();
$this
->assertEquals(0, count($errors));
}
public function testSaveConfigurationSubmit() : void {
$this
->drupalLogin($this->adminUser);
$edit = [
'textfield' => "The moose in the noose ate the goose who was loose.",
];
$this
->drupalPostForm($this
->getPath(), $edit, 'Save configuration');
}
}