WebformOptionsLimitEntityReferenceTest.php in Webform 8.5
File
modules/webform_options_limit/tests/src/Functional/WebformOptionsLimitEntityReferenceTest.php
View source
<?php
namespace Drupal\Tests\webform_options_limit\Functional;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformOptionsLimitEntityReferenceTest extends WebformBrowserTestBase {
public static $modules = [
'webform',
'node',
'webform_options_limit',
'webform_options_limit_test',
];
public function testOptionsLimit() {
$webform = Webform::load('test_handler_options_limit_ent');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/webform/test_handler_options_limit_ent');
$this
->assertRaw('options_limits_entity_select is not available');
$this
->createContentType([
'type' => 'page',
]);
$node_1 = $this
->createNode();
$node_2 = $this
->createNode();
$node_3 = $this
->createNode();
$this
->drupalGet('/webform/test_handler_options_limit_ent');
$this
->assertNoRaw('options_limits_entity_select is not available');
$this
->assertRaw('<option value="' . $node_1
->id() . '">');
$this
->assertRaw('<option value="' . $node_2
->id() . '">');
$this
->assertRaw('<option value="' . $node_3
->id() . '">');
$this
->postSubmission($webform, [
'options_limits_entity_select' => [
$node_1
->id(),
],
]);
$this
->postSubmission($webform, [
'options_limits_entity_select' => [
$node_1
->id(),
],
]);
$this
->postSubmission($webform, [
'options_limits_entity_select' => [
$node_1
->id(),
],
]);
$this
->drupalGet('/webform/test_handler_options_limit_ent');
$this
->assertRaw('data-webform-select-options-disabled="1"');
}
}