public function PremiumContentTest::testQueryAccessAll in Node Option Premium 8
Tests searching when premium content is accessible to all.
File
- tests/
src/ Kernel/ Plugin/ search_api/ processor/ PremiumContentTest.php, line 106
Class
- PremiumContentTest
- Tests the "Premium content" processor.
Namespace
Drupal\Tests\nopremium\Kernel\Plugin\search_api\processorCode
public function testQueryAccessAll() {
$permissions = [
'access content',
'view full premium content of any type',
];
user_role_grant_permissions('anonymous', $permissions);
$this->index
->reindex();
$this
->indexItems();
$this
->assertEquals(2, $this->index
->getTrackerInstance()
->getIndexedItemsCount(), '2 items indexed, as expected.');
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($this->index);
$result = $query
->execute();
$expected = [
'node' => [
0,
1,
],
];
$this
->assertResults($result, $expected);
}