You are here

public function QueuerConfigFormTest::testSaveConfigurationSubmit in URLs queuer 8

Tests save button presence/absence.

Overrides PluginConfigFormTestBase::testSaveConfigurationSubmit

File

tests/src/Functional/QueuerConfigFormTest.php, line 38

Class

QueuerConfigFormTest
Tests \Drupal\purge_queuer_url\Form\ConfigurationForm.

Namespace

Drupal\Tests\purge_queuer_url\Functional

Code

public function testSaveConfigurationSubmit() : void {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet($this
    ->getPath());

  // Assert the standard fields and their default values.
  $this
    ->assertSession()
    ->fieldExists('edit-queue-paths');
  $this
    ->assertSession()
    ->checkboxNotChecked('edit-queue-paths');
  $this
    ->assertSession()
    ->fieldExists('edit-host-override');
  $this
    ->assertSession()
    ->checkboxNotChecked('edit-host-override');
  $this
    ->assertSession()
    ->fieldExists('edit-host');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-host', '');
  $this
    ->assertSession()
    ->fieldExists('edit-scheme-override');
  $this
    ->assertSession()
    ->checkboxNotChecked('edit-scheme-override');
  $this
    ->assertSession()
    ->fieldExists('edit-scheme');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-scheme', 'http');
  $this
    ->assertRaw('Clear traffic history');

  // Test that direct configuration changes are reflected properly.
  $this
    ->config('purge_queuer_url.settings')
    ->set('queue_paths', TRUE)
    ->set('host_override', TRUE)
    ->set('host', 'foobar.baz')
    ->set('scheme_override', TRUE)
    ->set('scheme', 'https')
    ->save();
  $this
    ->drupalGet($this
    ->getPath());
  $this
    ->assertSession()
    ->checkboxChecked('edit-queue-paths');
  $this
    ->assertSession()
    ->checkboxChecked('edit-host-override');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-host', 'foobar.baz');
  $this
    ->assertSession()
    ->checkboxChecked('edit-scheme-override');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-scheme', 'https');
}