Mercurial > hg > isophonics-drupal-site
comparison core/modules/comment/tests/src/Functional/CommentStatusFieldAccessTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\comment\Functional; | |
4 | |
5 use Drupal\comment\Tests\CommentTestTrait; | |
6 use Drupal\node\Entity\NodeType; | |
7 use Drupal\Tests\BrowserTestBase; | |
8 | |
9 /** | |
10 * Tests comment status field access. | |
11 * | |
12 * @group comment | |
13 */ | |
14 class CommentStatusFieldAccessTest extends BrowserTestBase { | |
15 | |
16 use CommentTestTrait; | |
17 | |
18 /** | |
19 * {@inheritdoc} | |
20 */ | |
21 public $profile = 'testing'; | |
22 | |
23 /** | |
24 * Comment admin. | |
25 * | |
26 * @var \Drupal\user\UserInterface | |
27 */ | |
28 protected $commentAdmin; | |
29 | |
30 /** | |
31 * Node author. | |
32 * | |
33 * @var \Drupal\user\UserInterface | |
34 */ | |
35 protected $nodeAuthor; | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 public static $modules = [ | |
41 'node', | |
42 'comment', | |
43 'user', | |
44 'system', | |
45 'text', | |
46 ]; | |
47 | |
48 /** | |
49 * {@inheritdoc} | |
50 */ | |
51 protected function setUp() { | |
52 parent::setUp(); | |
53 $node_type = NodeType::create([ | |
54 'type' => 'article', | |
55 'name' => t('Article'), | |
56 ]); | |
57 $node_type->save(); | |
58 $this->nodeAuthor = $this->drupalCreateUser([ | |
59 'create article content', | |
60 'skip comment approval', | |
61 'post comments', | |
62 'edit own comments', | |
63 'access comments', | |
64 'administer nodes', | |
65 ]); | |
66 $this->commentAdmin = $this->drupalCreateUser([ | |
67 'administer comments', | |
68 'create article content', | |
69 'edit own comments', | |
70 'skip comment approval', | |
71 'post comments', | |
72 'access comments', | |
73 'administer nodes', | |
74 ]); | |
75 $this->addDefaultCommentField('node', 'article'); | |
76 } | |
77 | |
78 /** | |
79 * Tests comment status field access. | |
80 */ | |
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]'); | |
86 $this->submitForm([ | |
87 'title[0][value]' => 'Node 1', | |
88 ], t('Save')); | |
89 $assert->fieldExists('subject[0][value]'); | |
90 $this->drupalLogin($this->commentAdmin); | |
91 $this->drupalGet('node/add/article'); | |
92 $assert->fieldExists('comment[0][status]'); | |
93 $this->submitForm([ | |
94 'title[0][value]' => 'Node 2', | |
95 ], t('Save')); | |
96 $assert->fieldExists('subject[0][value]'); | |
97 } | |
98 | |
99 } |