public function ContentAccessTest::testQueryAccessComments in Search API 8
Tests searching when only comments are accessible.
File
- tests/
src/ Kernel/ Processor/ ContentAccessTest.php, line 161
Class
- ContentAccessTest
- Tests the "Content access" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function testQueryAccessComments() {
user_role_grant_permissions('anonymous', [
'access comments',
]);
$this->index
->reindex();
$this
->indexItems();
$this
->assertEquals(5, $this->index
->getTrackerInstance()
->getIndexedItemsCount(), '5 items indexed, as expected.');
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($this->index);
$result = $query
->execute();
$this
->assertResults($result, [
'user' => [
0,
],
'comment' => [
0,
],
]);
}