You are here

function ArgumentUserUIDTest::testCommentUserUIDTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php \Drupal\comment\Tests\Views\ArgumentUserUIDTest::testCommentUserUIDTest()

File

core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php, line 28
Contains \Drupal\comment\Tests\Views\ArgumentUserUIDTest.

Class

ArgumentUserUIDTest
Tests the user posted or commented argument handler.

Namespace

Drupal\comment\Tests\Views

Code

function testCommentUserUIDTest() {

  // Add an additional comment which is not created by the user.
  $new_user = User::create([
    'name' => 'new user',
  ]);
  $new_user
    ->save();
  $comment = Comment::create([
    'uid' => $new_user->uid->value,
    'entity_id' => $this->nodeUserCommented
      ->id(),
    'entity_type' => 'node',
    'field_name' => 'comment',
    'subject' => 'if a woodchuck could chuck wood.',
  ]);
  $comment
    ->save();
  $view = Views::getView('test_comment_user_uid');
  $this
    ->executeView($view, array(
    $this->account
      ->id(),
  ));
  $result_set = array(
    array(
      'nid' => $this->nodeUserPosted
        ->id(),
    ),
    array(
      'nid' => $this->nodeUserCommented
        ->id(),
    ),
  );
  $column_map = array(
    'nid' => 'nid',
  );
  $this
    ->assertIdenticalResultset($view, $result_set, $column_map);
}