public function PremiumContentTest::testQueryAccessNonPremium in Node Option Premium 8
Tests searching when there's no access to premium nodes.
File
- tests/
src/ Kernel/ Plugin/ search_api/ processor/ PremiumContentTest.php, line 127
Class
- PremiumContentTest
- Tests the "Premium content" processor.
Namespace
Drupal\Tests\nopremium\Kernel\Plugin\search_api\processorCode
public function testQueryAccessNonPremium() {
$permissions = [
'access content',
];
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' => [
1,
],
];
$this
->assertResults($result, $expected);
}