Skip to content
ArgumentUserUIDTest.php 1.22 KiB
Newer Older
namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
 * Tests the user posted or commented argument handler.
 *
 * @group comment
 */
class ArgumentUserUIDTest extends CommentTestBase {

  public static $testViews = ['test_comment_user_uid'];
  public 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, [$this->account->id()]);
    $result_set = [
      [
        'nid' => $this->nodeUserPosted->id(),
        'nid' => $this->nodeUserCommented->id(),
    $this->assertIdenticalResultset($view, $result_set, $column_map);