WebformElementCheckboxTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementCheckboxTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\webform\Entity\Webform;
class WebformElementCheckboxTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_checkbox',
];
public function testCheckboxValue() {
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('test_element_checkbox');
$edit = [
'checkbox' => TRUE,
'checkbox_raw' => TRUE,
'checkbox_return_value' => 'custom_return_value',
'checkbox_return_value_raw' => 'custom_return_value_raw',
];
$sid = $this
->postSubmission($webform, $edit);
$this
->assertRaw("checkbox: 1\ncheckbox_raw: 1\ncheckbox_return_value: custom_return_value\ncheckbox_return_value_raw: custom_return_value_raw");
$this
->drupalGet('/admin/structure/webform/manage/test_element_checkbox/submission/' . $sid);
$this
->assertPattern('#<label>checkbox</label>\\s+Yes\\s+</div>#');
$this
->assertPattern('#<label>checkbox_raw</label>\\s+1\\s+</div>#');
$this
->assertPattern('#<label>checkbox_return_value</label>\\s+Yes\\s+</div>#');
$this
->assertPattern('#<label>checkbox_return_value_raw</label>\\s+custom_return_value_raw\\s+</div>#');
}
}