]);
$view->
save();
/** @var \Drupal\Core\Session\AccountSwitcherInterface $account_switcher */
$account_switcher = \Drupal::
service('account_switcher'
);
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::
service('renderer'
);
$account_switcher->
switchTo($this->adminUser
);
$executable = Views::
getView($view_id);
$build =
$executable->
preview();
$this->
setRawContent($renderer->
renderRoot($build));
$this->
assertLink('My comment title'
);
$this->
assertLink('Anonymous comment title'
);
// Display plugin of the view is showing the name field. When comment
// belongs to an authenticated user the name field has no value.
$comment_author =
$this->
xpath('//div[contains(@class, :class)]/span[normalize-space(text())=""]',
[ ':class' => 'views-field-subject',
]);
$this->
assertNotEmpty($comment_author);