WebformNodeEntityReferenceTest.php in Webform 6.x
File
modules/webform_node/tests/src/Functional/WebformNodeEntityReferenceTest.php
View source
<?php
namespace Drupal\Tests\webform_node\Functional;
use Drupal\node\Entity\Node;
class WebformNodeEntityReferenceTest extends WebformNodeBrowserTestBase {
public static $modules = [
'user',
'webform',
'webform_node',
'webform_node_test_multiple',
];
protected static $testWebforms = [
'webform_node_test_multiple_a',
'webform_node_test_multiple_b',
];
public function testEntityReference() {
$user_data = \Drupal::service('user.data');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/node/1');
$this
->assertRaw('webform_test_multiple_a');
$this
->assertRaw('textfield_a');
$this
->assertRaw('webform_test_multiple_b');
$this
->assertRaw('textfield_a');
$this
->drupalGet('/node/1/webform/test');
$this
->assertNoRaw('textfield_a');
$this
->assertRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/submissions');
$this
->assertNoRaw('textfield_a');
$this
->assertRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/download');
$this
->assertNoRaw('textfield_a');
$this
->assertRaw('textfield_b');
$this
->assertNull($user_data
->get('webform_node', $this->rootUser
->id(), 1));
$this
->drupalGet('/node/1/webform/test');
$this
->clickLink('Test: Webform Node Multiple A');
$this
->assertEqual([
'target_id' => 'webform_node_test_multiple_a',
], $user_data
->get('webform_node', $this->rootUser
->id(), 1));
$this
->drupalGet('/node/1/webform/test');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/submissions');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/download');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
$this
->drupalGet('/node/1/webform/test');
$this
->clickLink('Test: Webform Node Multiple A');
$this
->assertEqual([
'target_id' => 'webform_node_test_multiple_a',
], $user_data
->get('webform_node', $this->rootUser
->id(), 1));
$this
->drupalGet('/node/1/webform/test');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/submissions');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
$this
->drupalGet('/node/1/webform/results/download');
$this
->assertRaw('textfield_a');
$this
->assertNoRaw('textfield_b');
Node::load(1)
->delete();
$this
->assertNull($user_data
->get('webform_node', $this->rootUser
->id(), 1));
}
}