WebformWizardBasicJavaScriptTest.php in Webform 8.5
File
tests/src/FunctionalJavascript/Wizard/WebformWizardBasicJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript\Wizard;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\FunctionalJavascript\WebformWebDriverTestBase;
class WebformWizardBasicJavaScriptTest extends WebformWebDriverTestBase {
protected static $testWebforms = [
'test_form_wizard_basic',
];
public function testBasicWizard() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$webform = Webform::load('test_form_wizard_basic');
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertQuery();
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery();
$webform
->setSetting('wizard_track', 'name')
->save();
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertQuery();
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery('page=page_2');
$page
->pressButton('edit-wizard-prev');
$assert_session
->waitForText('Element 1');
$this
->assertQuery('page=page_1');
$this
->drupalGet('/webform/test_form_wizard_basic', [
'query' => [
'custom_param' => '1',
],
]);
$this
->assertRaw('Element 1');
$this
->assertQuery('custom_param=1');
$page
->pressButton('edit-wizard-next');
$assert_session
->waitForText('Element 2');
$this
->assertQuery('custom_param=1&page=page_2');
$page
->pressButton('edit-wizard-prev');
$assert_session
->waitForText('Element 1');
$this
->assertQuery('custom_param=1&page=page_1');
$webform
->setSetting('ajax', TRUE);
$webform
->save();
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('Element 1');
$this
->assertEqual('', $page
->findById('drupal-live-announce')
->getText());
$page
->pressButton('Next >');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 2" loaded. (2 of 4)');
$page
->pressButton('< Previous');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 1" loaded. (1 of 4)');
$page
->pressButton('Next >');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Page 2" loaded. (2 of 4)');
$page
->pressButton('Preview');
$assert_session
->waitForText('"Test: Webform: Wizard basic: Preview" loaded. (3 of 4)');
}
protected function assertQuery($expected_query = '') {
$actual_query = parse_url($this
->getSession()
->getCurrentUrl(), PHP_URL_QUERY) ?: '';
$this
->assertEquals($expected_query, $actual_query);
}
}