public function RoleAccessTest::testIdBasedCurrentUser in Search API 8
Tests the account in the processor when it's based on an ID.
File
- tests/
src/ Kernel/ Processor/ RoleAccessTest.php, line 188
Class
- RoleAccessTest
- Tests the "Role-based access" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function testIdBasedCurrentUser() {
$allowed_foo = $this
->createTestNode('allow for foo role');
$this
->createTestNode('allow for bar role');
$this->index
->reindex();
$this
->indexItems();
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($this->index);
$query
->setOption('search_api_access_account', $this->testUsers['foo']
->id());
$result = $query
->execute();
$this
->assertResults($result, [
'node' => [
$allowed_foo,
],
]);
}