3 namespace Drupal\Tests\comment\Functional;
5 use Drupal\comment\Tests\CommentTestTrait;
6 use Drupal\node\Entity\NodeType;
7 use Drupal\Tests\BrowserTestBase;
10 * Tests comment status field access.
14 class CommentStatusFieldAccessTest extends BrowserTestBase {
21 public $profile = 'testing';
26 * @var \Drupal\user\UserInterface
28 protected $commentAdmin;
33 * @var \Drupal\user\UserInterface
35 protected $nodeAuthor;
40 public static $modules = [
51 protected function setUp() {
53 $node_type = NodeType::create([
55 'name' => t('Article'),
58 $this->nodeAuthor = $this->drupalCreateUser([
59 'create article content',
60 'skip comment approval',
66 $this->commentAdmin = $this->drupalCreateUser([
67 'administer comments',
68 'create article content',
70 'skip comment approval',
75 $this->addDefaultCommentField('node', 'article');
79 * Tests comment status field access.
81 public function testCommentStatusFieldAccessStatus() {
82 $this->drupalLogin($this->nodeAuthor);
83 $this->drupalGet('node/add/article');
84 $assert = $this->assertSession();
85 $assert->fieldNotExists('comment[0][status]');
87 'title[0][value]' => 'Node 1',
89 $assert->fieldExists('subject[0][value]');
90 $this->drupalLogin($this->commentAdmin);
91 $this->drupalGet('node/add/article');
92 $assert->fieldExists('comment[0][status]');
94 'title[0][value]' => 'Node 2',
96 $assert->fieldExists('subject[0][value]');