WebformOptionsLimitBooleanTest.php in Webform 8.5
File
modules/webform_options_limit/tests/src/Functional/WebformOptionsLimitBooleanTest.php
View source
<?php
namespace Drupal\Tests\webform_options_limit\Functional;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformOptionsLimitBooleanTest extends WebformBrowserTestBase {
public static $modules = [
'webform',
'webform_options_limit',
'webform_options_limit_test',
];
public function testOptionsLimit() {
$webform = Webform::load('test_handler_boolean_limit');
$this
->drupalGet('/webform/test_handler_boolean_limit');
$this
->assertRaw('<label for="edit-boolean-limit-default" class="option">boolean_limit_default [1 remaining]</label>');
$this
->assertRaw('<div id="edit-boolean-limit-message--description" class="webform-element-description">2 options remaining / 2 limit / 0 total</div>');
$this
->assertRaw('<label for="edit-boolean-limit-remove" class="option">boolean_limit_remove [3 remaining]</label>');
$sid_1 = $this
->postSubmission($webform);
$this
->assertRaw('<label for="edit-boolean-limit-default" class="option">boolean_limit_default [0 remaining]</label>');
$this
->assertCssSelect('#edit-boolean-limit-default[disabled]');
$this
->assertRaw('boolean_limit_default is not available.');
$this
->assertRaw('<div id="edit-boolean-limit-message--description" class="webform-element-description">1 option remaining / 2 limit / 1 total</div>');
$this
->assertCssSelect('#edit-boolean-limit-remove');
$this
->assertRaw('<label for="edit-boolean-limit-remove" class="option">boolean_limit_remove [2 remaining]</label>');
$this
->postSubmission($webform);
$this
->postSubmission($webform);
$this
->assertRaw('<label for="edit-boolean-limit-default" class="option">boolean_limit_default [0 remaining]</label>');
$this
->assertCssSelect('#edit-boolean-limit-default[disabled]');
$this
->assertRaw('boolean_limit_default is not available.');
$this
->assertCssSelect('#edit-boolean-limit-message[disabled]');
$this
->assertRaw('boolean_limit_message is not available.');
$this
->assertNoCssSelect('#edit-boolean-limit-remove');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet("/admin/structure/webform/manage/test_handler_boolean_limit/submission/{$sid_1}/edit");
$this
->assertNoCssSelect('#edit-boolean-limit-default[disabled]');
$this
->assertNoCssSelect('#edit-boolean-limit-message[disabled]');
$this
->assertCssSelect('#edit-boolean-limit-remove');
}
}