public function ContentAccessTest::testNodeGrantsChange in Search API 8
Tests that acquiring node grants leads to re-indexing of that node.
File
- tests/
src/ Kernel/ Processor/ ContentAccessTest.php, line 315
Class
- ContentAccessTest
- Tests the "Content access" processor.
Namespace
Drupal\Tests\search_api\Kernel\ProcessorCode
public function testNodeGrantsChange() {
$this->index
->setOption('index_directly', FALSE)
->save();
$this
->indexItems();
$remaining = $this->index
->getTrackerInstance()
->getRemainingItems();
$this
->assertEquals([], $remaining, 'All items were indexed.');
/** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */
$access_control_handler = \Drupal::entityTypeManager()
->getAccessControlHandler('node');
$access_control_handler
->acquireGrants($this->nodes[0]);
$expected = [
'entity:comment/' . $this->comments[0]
->id() . ':en',
'entity:node/' . $this->nodes[0]
->id() . ':en',
];
$remaining = $this->index
->getTrackerInstance()
->getRemainingItems();
sort($remaining);
$this
->assertEquals($expected, $remaining, 'The expected items were marked as "changed" when changing node access grants.');
}