$view = Views::
getView('taxonomy_term'
);
$view->
initDisplay();
$view->
setArguments([$term->
id()]);
$view->
build();
/** @var \Drupal\Core\Database\Query\Select $query */
$query =
$view->build_info
['query'
];
$tables =
$query->
getTables();
// Ensure that the join to node_field_data is not added by default.
$this->
assertEquals(['node_field_data', 'taxonomy_index'
],
array_keys($tables));
// Ensure that the filter to the language column is not there by default.
$condition =
$query->
conditions();
// We only want to check the no. of conditions in the query.
unset($condition['#conjunction'
]);
$this->
assertCount(1,
$condition);
// Clear permissions for anonymous users to check access for default views.
Role::
load(RoleInterface::ANONYMOUS_ID
)->
revokePermission('access content'
)->
save();
// Test the default views disclose no data by default.
$this->
drupalLogout();
$this->
drupalGet('taxonomy/term/' .
$term->
id());
$this->
assertSession()->
statusCodeEquals(403
);