WebformOptionsCustomEntityTest.php in Webform 8.5
File
modules/webform_options_custom/tests/src/Functional/WebformOptionsCustomEntityTest.php
View source
<?php
namespace Drupal\Tests\webform_options_custom\Functional;
use Drupal\node\Entity\Node;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
use Drupal\webform\Entity\Webform;
class WebformOptionsCustomEntityTest extends WebformBrowserTestBase {
public static $modules = [
'node',
'webform',
'webform_options_custom',
'webform_options_custom_entity_test',
];
public function testOptionsCustomEntity() {
$webform = Webform::load('test_element_options_custom_ent');
$node = Node::load(1);
$this
->drupalGet('/webform/test_element_options_custom_ent');
$this
->assertRaw('<div data-name="Room 1" data-option-value="1">Room 1</div>');
$this
->assertRaw('<div data-name="Room 2" data-option-value="2">Room 2</div>');
$this
->assertRaw('<div data-name="Room 3" data-option-value="3">Room 3</div>');
$this
->assertRaw('data-descriptions="{"1":"This is room number #1. [1 remaining]","2":"This is room number #2. [1 remaining]","3":"This is room number #3. [1 remaining]"}"');
$this
->postSubmission($webform, [
'webform_options_custom_entity[select][]' => '1',
], 'Preview');
$this
->assertRaw('<a href="' . $node
->toUrl()
->setAbsolute()
->toString() . '" hreflang="en">Room 1 -- This is room number #1.</a>');
}
}