3 namespace Drupal\Tests\comment\Functional;
6 use Drupal\comment\Tests\CommentTestTrait;
7 use Drupal\node\Entity\NodeType;
8 use Drupal\Tests\BrowserTestBase;
11 * Tests comment status field access.
15 class CommentStatusFieldAccessTest extends BrowserTestBase {
22 public $profile = 'testing';
27 * @var \Drupal\user\UserInterface
29 protected $commentAdmin;
34 * @var \Drupal\user\UserInterface
36 protected $nodeAuthor;
41 public static $modules = [
52 protected function setUp() {
54 $node_type = NodeType::create([
56 'name' => t('Article'),
59 $this->nodeAuthor = $this->drupalCreateUser([
60 'create article content',
61 'skip comment approval',
67 $this->commentAdmin = $this->drupalCreateUser([
68 'administer comments',
69 'create article content',
71 'skip comment approval',
76 $this->addDefaultCommentField('node', 'article');
80 * Tests comment status field access.
82 public function testCommentStatusFieldAccessStatus() {
83 $this->drupalLogin($this->nodeAuthor);
84 $this->drupalGet('node/add/article');
85 $assert = $this->assertSession();
86 $assert->fieldNotExists('comment[0][status]');
88 'title[0][value]' => 'Node 1',
89 ], t('Save and publish'));
90 $assert->fieldExists('subject[0][value]');
91 $this->drupalLogin($this->commentAdmin);
92 $this->drupalGet('node/add/article');
93 $assert->fieldExists('comment[0][status]');
95 'title[0][value]' => 'Node 2',
96 ], t('Save and publish'));
97 $assert->fieldExists('subject[0][value]');