public function RoleAccessTest::testQueryAccessBypass in Search API 8
Tests whether the "search_api_bypass_access" query option is respected.
File
- tests/
src/ Kernel/ Processor/ RoleAccessTest.php, line 209
Class
- RoleAccessTest
- Tests the "Role-based access" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function testQueryAccessBypass() {
$disallowed = $this
->createTestNode('disallowed');
$this->index
->reindex();
$this
->indexItems();
$this
->assertEquals(1, $this->index
->getTrackerInstance()
->getIndexedItemsCount());
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($this->index, [
'search_api_bypass_access' => TRUE,
]);
$result = $query
->execute();
$expected = [
'node' => [
$disallowed,
],
];
$this
->assertResults($result, $expected);
}