3 namespace Drupal\comment\Tests\Views;
5 use Drupal\comment\Entity\Comment;
6 use Drupal\user\Entity\User;
7 use Drupal\views\Views;
10 * Tests the user posted or commented filter handler.
12 * The actual stuff is done in the parent class.
16 class FilterUserUIDTest extends CommentTestBase {
19 * Views used by this test.
23 public static $testViews = ['test_comment_user_uid'];
25 public function testCommentUserUIDTest() {
26 $view = Views::getView('test_comment_user_uid');
28 $view->removeHandler('default', 'argument', 'uid_touch');
30 // Add an additional comment which is not created by the user.
31 $new_user = User::create(['name' => 'new user']);
34 $comment = Comment::create([
35 'uid' => $new_user->uid->value,
36 'entity_id' => $this->nodeUserCommented->id(),
37 'entity_type' => 'node',
38 'field_name' => 'comment',
39 'subject' => 'if a woodchuck could chuck wood.',
45 'table' => 'node_field_data',
46 'field' => 'uid_touch',
47 'value' => [$this->loggedInUser->id()],
49 $view->addHandler('default', 'filter', 'node_field_data', 'uid_touch', $options);
50 $this->executeView($view, [$this->account->id()]);
53 'nid' => $this->nodeUserPosted->id(),
56 'nid' => $this->nodeUserCommented->id(),
59 $column_map = ['nid' => 'nid'];
60 $this->assertIdenticalResultset($view, $result_set, $column_map);