You are here

WebformWizardCustomTest.php in Webform 6.x

Same filename and directory in other branches
  1. 8.5 tests/src/Functional/Wizard/WebformWizardCustomTest.php

File

tests/src/Functional/Wizard/WebformWizardCustomTest.php
View source
<?php

namespace Drupal\Tests\webform\Functional\Wizard;


/**
 * Tests for webform custom wizard.
 *
 * @group webform
 */
class WebformWizardCustomTest extends WebformWizardTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'webform',
    'webform_test_wizard_custom',
  ];

  /**
   * Webforms to load.
   *
   * @var array
   */
  protected static $testWebforms = [
    'test_form_wizard_custom',
  ];

  /**
   * Test webform custom wizard.
   */
  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');
  }

}

Classes

Namesort descending Description
WebformWizardCustomTest Tests for webform custom wizard.