function CToolsWizardTest::testWizardSteps
Same name in other branches
- 8.x-3.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\FunctionalCode
public function testWizardSteps() {
$this->drupalGet('ctools/wizard');
$this->assertSession()
->pageTextContains('Form One');
$this->dumpHeaders = TRUE;
// 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, $this->t('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([], $this->t('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([], $this->t('Next'));
$edit = [
'two' => 'Second test',
];
$this->submitForm($edit, $this->t('Finish'));
// Check that the wizard finished properly.
$this->assertSession()
->pageTextContains('Value One: test');
$this->assertSession()
->pageTextContains('Value Two: Second test');
}