View source
<?php
namespace Drupal\Tests\webform\Functional\Wizard;
use Drupal\webform\Entity\Webform;
class WebformWizardBasicTest extends WebformWizardTestBase {
protected static $testWebforms = [
'test_form_wizard_basic',
];
public function testBasicWizard() {
$this
->drupalLogin($this->rootUser);
$wizard_webform = Webform::load('test_form_wizard_basic');
$this
->drupalPostForm('/webform/test_form_wizard_basic', [], 'Next >');
$this
->drupalPostForm(NULL, [], 'Submit');
$sid = $this
->getLastSubmissionId($wizard_webform);
$this
->drupalGet("admin/structure/webform/manage/test_form_wizard_basic/submission/{$sid}/edit");
$this
->assertCurrentPage('Page 1', 'page_1');
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertCurrentPage('Page 2', 'page_2');
$this
->drupalPostForm(NULL, [], 'Save');
$this
->assertRaw('Submission updated in <em class="placeholder">Test: Webform: Wizard basic</em>.');
$this
->assertCurrentPage('Page 1', 'page_1');
$this
->drupalGet("admin/structure/webform/manage/test_form_wizard_basic/submission/{$sid}/edit/all");
$this
->assertResponse(200);
$this
->assertRaw('<summary role="button" aria-controls="edit-page-1" aria-expanded="false" aria-pressed="false">Page 1</summary>');
$this
->assertRaw('<summary role="button" aria-controls="edit-page-2" aria-expanded="false" aria-pressed="false">Page 2</summary>');
$contact_webform = Webform::load('contact');
$sid = $this
->postSubmissionTest($contact_webform);
$this
->drupalGet("admin/structure/webform/manage/contact/submission/{$sid}/edit/all");
$this
->assertResponse(403);
$wizard_webform
->setSetting('wizard_track', 'name')
->setSetting('confirmation_type', 'inline')
->save();
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertNoRaw('data-webform-wizard-current-page');
$this
->assertRaw('data-webform-wizard-page="page_2" data-drupal-selector="edit-wizard-next"');
$this
->drupalPostForm('/webform/test_form_wizard_basic', [], 'Next >');
$this
->assertRaw('data-webform-wizard-current-page="page_2"');
$this
->assertRaw('data-webform-wizard-page="page_1" data-drupal-selector="edit-wizard-prev"');
$this
->assertRaw('data-webform-wizard-page="webform_preview" data-drupal-selector="edit-preview-next"');
$this
->drupalPostForm(NULL, [], 'Preview');
$this
->assertRaw('data-webform-wizard-current-page="webform_preview"');
$this
->assertRaw('data-webform-wizard-page="page_2" data-drupal-selector="edit-preview-prev"');
$this
->assertRaw('data-webform-wizard-page="webform_confirmation" data-drupal-selector="edit-submit"');
$this
->drupalPostForm(NULL, [], 'Submit');
$this
->assertRaw('data-webform-wizard-current-page="webform_confirmation"');
$wizard_webform
->setSetting('wizard_track', 'index')
->save();
$this
->drupalGet('/webform/test_form_wizard_basic');
$this
->assertRaw('data-webform-wizard-page="2" data-drupal-selector="edit-wizard-next"');
$this
->drupalPostForm('/webform/test_form_wizard_basic', [], 'Next >');
$this
->assertRaw('data-webform-wizard-current-page="2"');
$this
->assertRaw('data-webform-wizard-page="1" data-drupal-selector="edit-wizard-prev"');
$this
->assertRaw('data-webform-wizard-page="3" data-drupal-selector="edit-preview-next"');
$this
->drupalPostForm(NULL, [], 'Preview');
$this
->assertRaw('data-webform-wizard-current-page="3"');
$this
->assertRaw('data-webform-wizard-page="2" data-drupal-selector="edit-preview-prev"');
$this
->assertRaw('data-webform-wizard-page="4" data-drupal-selector="edit-submit"');
$this
->drupalPostForm(NULL, [], 'Submit');
$this
->assertRaw('data-webform-wizard-current-page="4"');
}
}