public function AccessCheckTest::testNoGrantedTermRestriction in Permissions by Term 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/AccessCheckTest.php \Drupal\Tests\permissions_by_term\Kernel\AccessCheckTest::testNoGrantedTermRestriction()
Return value
void
File
- tests/
src/ Kernel/ AccessCheckTest.php, line 58
Class
- AccessCheckTest
- Class AccessCheckTest
Namespace
Drupal\Tests\permissions_by_term\KernelCode
public function testNoGrantedTermRestriction() {
$database = $this->container
->get('database');
$database
->truncate('node_access')
->execute();
$this
->createRelationNoGrantedTerm();
\Drupal::configFactory()
->getEditable('permissions_by_term.settings.single_term_restriction')
->set('value', FALSE)
->save();
$this
->assertFalse($this->accessCheck
->canUserAccessByNodeId($this
->getNidNoGrantedTerm()));
node_access_rebuild();
$gids = $this->accessStorage
->getGids(\Drupal::service('current_user'));
$nodeAccess = $database
->select('node_access', 'na')
->fields('na', [
'nid',
])
->condition('na.gid', $gids['permissions_by_term'], 'IN')
->condition('na.realm', AccessStorage::NODE_ACCESS_REALM);
$permittedNids = $nodeAccess
->execute()
->fetchCol();
$this
->assertCount(0, $permittedNids);
}