WebformOptionsLimitSourceEntityTest.php in Webform 8.5
File
modules/webform_options_limit/tests/src/Functional/WebformOptionsLimitSourceEntityTest.php
View source
<?php
namespace Drupal\Tests\webform_options_limit\Functional;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform_node\Functional\WebformNodeBrowserTestBase;
class WebformOptionsLimitSourceEntityTest extends WebformNodeBrowserTestBase {
public static $modules = [
'webform',
'webform_node',
'webform_options_limit',
'webform_options_limit_test',
];
public function testSourceEnity() {
$webform = Webform::load('test_handler_options_limit');
$node = $this
->createWebformNode('test_handler_options_limit');
$this
->drupalGet('/node/' . $node
->id());
$this
->assertRaw('A [1 remaining]');
$this
->drupalGet('/webform/test_handler_options_limit');
$this
->assertRaw('A [1 remaining]');
$this
->postNodeSubmission($node);
$this
->drupalGet('/node/' . $node
->id());
$this
->assertRaw('A [0 remaining]');
$this
->drupalGet('/webform/test_handler_options_limit');
$this
->assertRaw('A [1 remaining]');
$this
->postSubmission($webform);
$this
->drupalGet('/node/' . $node
->id());
$this
->assertRaw('A [0 remaining]');
$this
->drupalGet('/webform/test_handler_options_limit');
$this
->assertRaw('A [0 remaining]');
$this
->purgeSubmissions();
$webform
->getHandler('options_limit_default')
->setSetting('limit_source_entity', FALSE);
$webform
->save();
$this
->drupalGet('/node/' . $node
->id());
$this
->assertRaw('A [1 remaining]');
$this
->drupalGet('/webform/test_handler_options_limit');
$this
->assertRaw('A [1 remaining]');
$this
->postNodeSubmission($node);
$this
->drupalGet('/node/' . $node
->id());
$this
->assertRaw('A [0 remaining]');
$this
->drupalGet('/webform/test_handler_options_limit');
$this
->assertRaw('A [0 remaining]');
}
}