QueuerConfigFormTest.php in Purge 8.3
File
modules/purge_queuer_coretags/tests/src/Functional/QueuerConfigFormTest.php
View source
<?php
namespace Drupal\Tests\purge_queuer_coretags\Functional;
use Drupal\purge_queuer_coretags\Form\ConfigurationForm;
use Drupal\Tests\purge_ui\Functional\Form\Config\QueuerConfigFormTestBase;
class QueuerConfigFormTest extends QueuerConfigFormTestBase {
public static $modules = [
'purge_queuer_coretags',
'purge_coretags_removed_test',
];
protected $pluginId = 'coretags';
protected $formClass = ConfigurationForm::class;
protected $formId = 'purge_queuer_coretags.configuration_form';
public function testDefaultFormState() : void {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->fieldExists('edit-blacklist-0');
$this
->assertSession()
->fieldExists('edit-blacklist-1');
$this
->assertSession()
->fieldExists('edit-blacklist-2');
$this
->assertSession()
->fieldExists('edit-blacklist-3');
$this
->assertSession()
->fieldExists('edit-blacklist-4');
$this
->assertSession()
->fieldExists('edit-blacklist-5');
$this
->assertSession()
->fieldExists('edit-blacklist-6');
$this
->assertSession()
->fieldExists('edit-blacklist-7');
$this
->assertSession()
->responseContains('value="4xx-response"');
$this
->assertSession()
->responseContains('value="config:core.extension"');
$this
->assertSession()
->responseContains('value="extensions"');
$this
->assertSession()
->responseContains('value="config:purge"');
$this
->assertSession()
->responseContains('value="theme_registry"');
$this
->assertSession()
->responseContains('value="config:field.storage"');
$this
->assertSession()
->responseContains('value="route_match"');
$this
->assertSession()
->responseContains('value="routes"');
$this
->assertSession()
->pageTextContains('Add prefix');
$this
->assertSession()
->pageTextContains('if you know what you are doing');
}
public function testSaveConfigurationSubmit() : void {
$this
->config('purge_queuer_coretags.settings')
->set('blacklist', [
'a',
'b',
'c',
'd',
])
->save();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->fieldExists('edit-blacklist-0');
$this
->assertSession()
->fieldExists('edit-blacklist-1');
$this
->assertSession()
->fieldExists('edit-blacklist-2');
$this
->assertSession()
->fieldExists('edit-blacklist-3');
$this
->assertSession()
->fieldNotExists('edit-blacklist-4');
$form = $this
->getFormInstance();
$form_state = $this
->getFormStateInstance();
$form_state
->addBuildInfo('args', $this->formArgs);
$form_state
->setValue('blacklist', [
'testvalue',
'',
'',
'',
]);
$this
->formBuilder()
->submitForm($form, $form_state);
$this
->assertSame(0, count($form_state
->getErrors()));
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains('testvalue');
$this
->assertSession()
->fieldExists('edit-blacklist-0');
$this
->assertSession()
->fieldNotExists('edit-blacklist-1');
}
}