WebformNodeAccessClosedTest.php in Webform 8.5
File
modules/webform_node/tests/src/Functional/Access/WebformNodeAccessClosedTest.php
View source
<?php
namespace Drupal\Tests\webform_node\Functional\Access;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform_node\Functional\WebformNodeBrowserTestBase;
class WebformNodeAccessClosedTest extends WebformNodeBrowserTestBase {
public static $modules = [
'webform',
'webform_node',
];
public function testAccessClosedT() {
$node = $this
->createWebformNode('contact');
$nid = $node
->id();
$account = $this
->drupalCreateUser([
'access content',
]);
$this
->drupalLogin($account);
$this
->drupalGet('/node/' . $node
->id());
$this
->assertResponse(200);
$this
->assertFieldByName('name', $account
->getAccountName());
$this
->assertFieldByName('email', $account
->getEmail());
$this
->drupalGet('/webform/contact', [
'query' => [
'source_entity_type' => 'node',
'source_entity_id' => $nid,
],
]);
$this
->assertResponse(200);
$this
->assertFieldByName('name', $account
->getAccountName());
$this
->assertFieldByName('email', $account
->getEmail());
$node->webform->status = FALSE;
$node
->save();
$this
->drupalGet('/node/' . $node
->id());
$this
->assertResponse(200);
$this
->assertNoFieldByName('name', $account
->getAccountName());
$this
->assertNoFieldByName('email', $account
->getEmail());
$this
->assertRaw('Sorry… This form is closed to new submissions.');
$this
->drupalGet('/webform/contact', [
'query' => [
'source_entity_type' => 'node',
'source_entity_id' => $nid,
],
]);
$this
->assertResponse(200);
$this
->assertNoFieldByName('name', $account
->getAccountName());
$this
->assertNoFieldByName('email', $account
->getEmail());
$this
->assertRaw('Sorry… This form is closed to new submissions.');
}
}