You are here

public function WebformWizardCustomTest::testCustomWizard in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Wizard/WebformWizardCustomTest.php \Drupal\Tests\webform\Functional\Wizard\WebformWizardCustomTest::testCustomWizard()

Test webform custom wizard.

File

tests/src/Functional/Wizard/WebformWizardCustomTest.php, line 29

Class

WebformWizardCustomTest
Tests for webform custom wizard.

Namespace

Drupal\Tests\webform\Functional\Wizard

Code

public function testCustomWizard() {

  // Check current page is #1.
  $this
    ->drupalGet('/webform/test_form_wizard_custom');
  $this
    ->assertCurrentPage('Wizard page #1', 'wizard_1');

  // Check next page is #2.
  $this
    ->drupalPostForm('/webform/test_form_wizard_custom', [], 'Next >');
  $this
    ->assertCurrentPage('Wizard page #2', 'wizard_2');

  // Check previous page is #1.
  $this
    ->drupalPostForm(NULL, [], '< Previous');
  $this
    ->assertCurrentPage('Wizard page #1', 'wizard_1');

  // Hide pages #3 and #4.
  $edit = [
    'pages[wizard_1]' => TRUE,
    'pages[wizard_2]' => TRUE,
    'pages[wizard_3]' => FALSE,
    'pages[wizard_4]' => FALSE,
    'pages[wizard_5]' => TRUE,
    'pages[wizard_6]' => TRUE,
    'pages[wizard_7]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Next >');

  // Check next page is #2.
  $this
    ->assertCurrentPage('Wizard page #2', 'wizard_2');

  // Check next page is #5.
  $this
    ->drupalPostForm(NULL, [], 'Next >');
  $this
    ->assertCurrentPage('Wizard page #5', 'wizard_5');

  // Check previous page is #2.
  $this
    ->drupalPostForm(NULL, [], '< Previous');
  $this
    ->assertCurrentPage('Wizard page #2', 'wizard_2');

  // Check previous page is #1.
  $this
    ->drupalPostForm(NULL, [], '< Previous');
  $this
    ->assertCurrentPage('Wizard page #1', 'wizard_1');
}