WebformElementActionsTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementActionsTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\webform\Entity\Webform;
class WebformElementActionsTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_actions',
'test_element_actions_buttons',
];
public function testActions() {
global $base_path;
$webform = Webform::load('test_element_actions');
$this
->drupalGet('/webform/test_element_actions');
$this
->assertRaw('<div style="border: 2px solid red; padding: 10px" data-drupal-selector="edit-actions-custom" class="form-actions webform-actions js-form-wrapper form-wrapper" id="edit-actions-custom">');
$this
->assertRaw('<input formnovalidate="formnovalidate" class="webform-button--draft custom-draft button js-form-submit form-submit" style="font-weight: bold" data-custom-draft data-drupal-selector="edit-actions-custom-draft" type="submit" id="edit-actions-custom-draft" name="op" value="{Custom draft}" />');
$this
->assertRaw('<input class="webform-button--next custom-wizard-next button js-form-submit form-submit" style="font-weight: bold" data-custom-wizard-next data-drupal-selector="edit-actions-custom-wizard-next" type="submit" id="edit-actions-custom-wizard-next" name="op" value="{Custom wizard next}" />');
$this
->assertRaw('<input formnovalidate="formnovalidate" class="webform-button--reset custom-reset button js-form-submit form-submit" style="font-weight: bold" data-custom-reset data-drupal-selector="edit-actions-custom-reset" type="submit" id="edit-actions-custom-reset" name="op" value="{Custom reset}" />');
$this
->assertCssSelect('[id="edit-actions-wizard-next-wizard-next"]');
$this
->assertNoCssSelect('[id="edit-actions-wizard-prev-wizard-prev"]');
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertNoCssSelect('[id="edit-actions-wizard-next-wizard-next"]');
$this
->assertCssSelect('[id="edit-actions-wizard-prev-wizard-prev"]');
$this
->drupalPostForm(NULL, [], 'Preview');
$this
->assertCssSelect('[id="edit-actions-submit-submit"]');
$this
->assertCssSelect('[id="edit-actions-reset-reset"]');
$this
->drupalPostForm(NULL, [], 'Submit');
$sid = $this
->getLastSubmissionId($webform);
$this
->assertNoCssSelect('.form-actions');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet("/admin/structure/webform/manage/test_element_actions/submission/{$sid}/edit");
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertRaw('<input class="webform-button--submit custom-update button button--primary js-form-submit form-submit" style="font-weight: bold" data-custom-update data-drupal-selector="edit-actions-custom-submit" type="submit" id="edit-actions-custom-submit" name="op" value="{Custom update}" />');
$this
->drupalPostForm('/webform/test_element_actions', [], 'Save Draft');
$sid = $this
->getLastSubmissionId($webform);
$this
->assertRaw('<a href="' . $base_path . 'admin/structure/webform/manage/test_element_actions/submission/' . $sid . '/delete?destination=' . $base_path . 'webform/test_element_actions" class="button button--danger custom-delete" style="font-weight: bold" data-custom-delete data-drupal-selector="edit-actions-custom-delete" id="edit-actions-custom-delete" hreflang="en">{Custom delete}</a>');
$this
->assertCssSelect('[id="edit-actions-delete"]');
$webform = Webform::load('test_element_actions_buttons');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/webform/test_element_actions_buttons');
$this
->assertRaw('<input formnovalidate="formnovalidate" class="webform-button--draft draft_button_attributes button js-form-submit form-submit" style="color: blue" data-drupal-selector="edit-actions-draft" type="submit" id="edit-actions-draft" name="op" value="Save Draft" />');
$this
->assertRaw('<input class="webform-button--next wizard_next_button_attributes button js-form-submit form-submit" style="color: yellow" data-drupal-selector="edit-actions-wizard-next" type="submit" id="edit-actions-wizard-next" name="op" value="Next >" />');
$this
->drupalPostForm('/webform/test_element_actions_buttons', [], 'Next >');
$this
->assertRaw('<input formnovalidate="formnovalidate" class="webform-button--previous wizard_prev_button_attributes button js-form-submit form-submit" style="color: yellow" data-drupal-selector="edit-actions-wizard-prev" type="submit" id="edit-actions-wizard-prev" name="op" value="< Previous" />');
$this
->assertRaw('<input class="webform-button--preview preview_next_button_attributes button js-form-submit form-submit" style="color: orange" data-drupal-selector="edit-actions-preview-next" type="submit" id="edit-actions-preview-next" name="op" value="Preview" />');
$this
->drupalPostForm(NULL, [], 'Preview');
$this
->assertRaw('<input formnovalidate="formnovalidate" class="webform-button--previous preview_prev_button_attributes button js-form-submit form-submit" style="color: orange" data-drupal-selector="edit-actions-preview-prev" type="submit" id="edit-actions-preview-prev" name="op" value="< Previous" />');
$this
->assertRaw('<input class="webform-button--submit form_submit_attributes button button--primary js-form-submit form-submit" style="color: green" data-drupal-selector="edit-actions-submit" type="submit" id="edit-actions-submit" name="op" value="Submit" />');
$this
->drupalPostForm(NULL, [], 'Submit');
$sid = $this
->getLastSubmissionId($webform);
$this
->drupalGet("/admin/structure/webform/manage/test_element_actions_buttons/submission/{$sid}/edit");
$this
->drupalPostForm(NULL, [], 'Next >');
$this
->assertRaw('<input class="webform-button--submit form_update_attributes button button--primary js-form-submit form-submit" style="color: purple" data-drupal-selector="edit-actions-submit" type="submit" id="edit-actions-submit" name="op" value="Save" />');
}
}