public function AccessCheckTest::testRequireAllTermsGrantedWithRestrictedTerms in Permissions by Term 8.2
File
- tests/
src/ Kernel/ AccessCheckTest.php, line 80
Class
- AccessCheckTest
- Class AccessCheckTest
Namespace
Drupal\Tests\permissions_by_term\KernelCode
public function testRequireAllTermsGrantedWithRestrictedTerms() : void {
$database = $this->container
->get('database');
$database
->truncate('node_access')
->execute();
$this
->createRelationOneGrantedTerm();
$this
->createRelationAllGrantedTerms();
\Drupal::configFactory()
->getEditable('permissions_by_term.settings')
->set('require_all_terms_granted', TRUE)
->save();
$this
->assertFalse($this->accessCheck
->canUserAccessByNode(Node::load($this
->getNidOneGrantedTerm())));
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(1, $permittedNids);
}