WebformElementPrivateTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementPrivateTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\webform\Entity\Webform;
class WebformElementPrivateTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_private',
];
public function testElementAccess() {
$normal_user = $this
->drupalCreateUser([
'view own webform submission',
]);
$webform = Webform::load('test_element_private');
$this
->drupalLogin($normal_user);
$this
->postSubmission($webform);
$sid = $this
->postSubmission($webform);
$this
->drupalGet('/webform/test_element_private');
$this
->assertNoFieldByName('private', '');
$this
->drupalGet("/webform/test_element_private/submissions/{$sid}");
$this
->assertNoCssSelect('#test_element_private--private');
$this
->assertNoRaw('<label>private</label>');
$this
->drupalGet('/webform/test_element_private/submissions');
$this
->assertNoRaw('<th specifier="element__private">');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/webform/test_element_private');
$this
->assertFieldByName('private', '');
$this
->drupalGet("/webform/test_element_private/submissions/{$sid}");
$this
->assertCssSelect('#test_element_private--private');
$this
->assertRaw('<label>private</label>');
$this
->drupalGet('/webform/test_element_private/submissions');
$this
->assertRaw('<th specifier="element__private">');
}
}