$account_switcher = \Drupal::
service('account_switcher'
);
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::
service('renderer'
);
$account_switcher->
switchTo($this->adminUser
);
$executable = Views::
getView('comment'
);
$build =
$executable->
preview($display_id);
$this->
setRawContent($renderer->
renderRoot($build));
// Assert the exposed filters on the admin page.
$this->
assertField('subject'
);
$this->
assertField('author_name'
);
$this->
assertField('langcode'
);
$elements =
$this->
cssSelect('input[type="checkbox"]'
);
$this->
assertCount(2,
$elements, 'There are two comments on the page.'
);
$this->
assertText($comment->
label());
$this->
assertText($comment_anonymous->
label());
$executable->
destroy();
// Test the Subject filter.
$executable->
setExposedInput(['subject' => 'Anonymous'
]);