function CToolsWizardTest::testWizardSteps

Same name in other branches
  1. 4.0.x tests/src/Functional/CToolsWizardTest.php \Drupal\Tests\ctools\Functional\CToolsWizardTest::testWizardSteps()

Test wizard Multistep form.

File

tests/src/Functional/CToolsWizardTest.php, line 26

Class

CToolsWizardTest
Tests basic wizard functionality.

Namespace

Drupal\Tests\ctools\Functional

Code

public function testWizardSteps() {
    $this->drupalGet('ctools/wizard');
    $this->assertSession()
        ->pageTextContains('Form One');
    // Check that $operations['one']['values'] worked.
    $this->assertSession()
        ->pageTextContains('Xylophone');
    // Submit first step in the wizard.
    $edit = [
        'one' => 'test',
    ];
    $this->drupalGet('ctools/wizard');
    $this->submitForm($edit, 'Next');
    // Redirected to the second step.
    $this->assertSession()
        ->pageTextContains('Form Two');
    $this->assertSession()
        ->pageTextContains('Dynamic value submitted: Xylophone');
    // Check that $operations['two']['values'] worked.
    $this->assertSession()
        ->pageTextContains('Zebra');
    // Hit previous to make sure our form value are preserved.
    $this->submitForm([], 'Previous');
    // Check the known form values.
    $this->assertSession()
        ->fieldValueEquals('one', 'test');
    $this->assertSession()
        ->pageTextContains('Xylophone');
    // Goto next step again and finish this wizard.
    $this->submitForm([], 'Next');
    $edit = [
        'two' => 'Second test',
    ];
    $this->submitForm($edit, 'Finish');
    // Check that the wizard finished properly.
    $this->assertSession()
        ->pageTextContains('Value One: test');
    $this->assertSession()
        ->pageTextContains('Value Two: Second test');
}