public function WebformElementSubmittedValueTest::testSubmittedValue in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/src/Functional/Element/WebformElementSubmittedValueTest.php \Drupal\Tests\webform\Functional\Element\WebformElementSubmittedValueTest::testSubmittedValue()
Tests submitted value.
File
- tests/
src/ Functional/ Element/ WebformElementSubmittedValueTest.php, line 24
Class
- WebformElementSubmittedValueTest
- Tests for webform submission value.
Namespace
Drupal\Tests\webform\Functional\ElementCode
public function testSubmittedValue() {
$this
->drupalLogin($this->rootUser);
// Create a submission.
$webform = Webform::load('test_element_submitted_value');
$sid = $this
->postSubmission($webform);
// Check the option 'three' is selected.
$this
->drupalGet("/webform/test_element_submission_value/submissions/{$sid}/edit");
$this
->assertRaw('<option value="three" selected="selected">Three</option>');
$this
->assertOptionSelected('edit-select', 'three');
$this
->assertOptionSelected('edit-select-multiple', 'three');
$this
->assertFieldChecked('edit-checkboxes-three');
// Remove option 'three' from all elements.
$elements = $webform
->getElementsDecoded();
foreach ($elements as &$element) {
unset($element['#options']['three']);
}
$webform
->setElements($elements);
$webform
->save();
// Check the option 'three' is still available and selected but
// the label is now just the value.
$this
->drupalGet("/webform/test_element_submission_value/submissions/{$sid}/edit");
$this
->assertNoRaw('<option value="three" selected="selected">Three</option>');
$this
->assertRaw('<option value="three" selected="selected">three</option>');
$this
->assertOptionSelected('edit-select', 'three');
$this
->assertOptionSelected('edit-select-multiple', 'three');
$this
->assertFieldChecked('edit-checkboxes-three');
}