db backup prior to drupal security update
[yaffs-website] / web / core / modules / comment / src / Tests / Views / ArgumentUserUIDTest.php
1 <?php
2
3 namespace Drupal\comment\Tests\Views;
4
5 use Drupal\comment\Entity\Comment;
6 use Drupal\user\Entity\User;
7 use Drupal\views\Views;
8
9 /**
10  * Tests the user posted or commented argument handler.
11  *
12  * @group comment
13  */
14 class ArgumentUserUIDTest extends CommentTestBase {
15
16   /**
17    * Views used by this test.
18    *
19    * @var array
20    */
21   public static $testViews = ['test_comment_user_uid'];
22
23   public function testCommentUserUIDTest() {
24     // Add an additional comment which is not created by the user.
25     $new_user = User::create(['name' => 'new user']);
26     $new_user->save();
27
28     $comment = Comment::create([
29       'uid' => $new_user->uid->value,
30       'entity_id' => $this->nodeUserCommented->id(),
31       'entity_type' => 'node',
32       'field_name' => 'comment',
33       'subject' => 'if a woodchuck could chuck wood.',
34     ]);
35     $comment->save();
36
37     $view = Views::getView('test_comment_user_uid');
38     $this->executeView($view, [$this->account->id()]);
39     $result_set = [
40       [
41         'nid' => $this->nodeUserPosted->id(),
42       ],
43       [
44         'nid' => $this->nodeUserCommented->id(),
45       ],
46     ];
47     $column_map = ['nid' => 'nid'];
48     $this->assertIdenticalResultset($view, $result_set, $column_map);
49   }
50
51 }