You are here

public function QueuerConfigFormTest::testSaveConfigurationSubmit in Purge 8.3

Same name in this branch
  1. 8.3 modules/purge_queuer_coretags/tests/src/Functional/QueuerConfigFormTest.php \Drupal\Tests\purge_queuer_coretags\Functional\QueuerConfigFormTest::testSaveConfigurationSubmit()
  2. 8.3 tests/modules/purge_queuer_test/tests/src/Functional/QueuerConfigFormTest.php \Drupal\Tests\purge_queuer_test\Functional\QueuerConfigFormTest::testSaveConfigurationSubmit()
  3. 8.3 modules/purge_ui/tests/src/Functional/Form/QueuerConfigFormTest.php \Drupal\Tests\purge_ui\Functional\Form\QueuerConfigFormTest::testSaveConfigurationSubmit()

Tests save button presence/absence.

Overrides PluginConfigFormTestBase::testSaveConfigurationSubmit

File

modules/purge_queuer_coretags/tests/src/Functional/QueuerConfigFormTest.php, line 65

Class

QueuerConfigFormTest
Tests \Drupal\purge_queuer_coretags\Form\ConfigurationForm.

Namespace

Drupal\Tests\purge_queuer_coretags\Functional

Code

public function testSaveConfigurationSubmit() : void {

  // Test that direct configuration changes are reflected properly.
  $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');

  // Submit 1 valid and three empty values, test the re-rendered form.
  $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');
}