protected function PBTKernelTestBase::createRelationOneGrantedTerm in Permissions by Term 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/PBTKernelTestBase.php \Drupal\Tests\permissions_by_term\Kernel\PBTKernelTestBase::createRelationOneGrantedTerm()
Return value
int
2 calls to PBTKernelTestBase::createRelationOneGrantedTerm()
- AccessCheckTest::testDisabledSingleTermRestriction in tests/
src/ Kernel/ AccessCheckTest.php - AccessCheckTest::testSingleTermRestrictionWithRestrictedTerms in tests/
src/ Kernel/ AccessCheckTest.php
File
- tests/
src/ Kernel/ PBTKernelTestBase.php, line 145
Class
- PBTKernelTestBase
- Class PBTKernelTestBase
Namespace
Drupal\Tests\permissions_by_term\KernelCode
protected function createRelationOneGrantedTerm() {
$term = Term::create([
'name' => 'term1',
'vid' => 'test',
]);
$term
->save();
$tids[] = $term
->id();
$this->accessStorage
->addTermPermissionsByUserIds([
\Drupal::service('current_user')
->id(),
], $term
->id());
$term = Term::create([
'name' => 'term2',
'vid' => 'test',
]);
$term
->save();
$tids[] = $term
->id();
$term = Term::create([
'name' => 'term3',
'vid' => 'test2',
]);
$term
->save();
$tids[] = $term
->id();
$this->accessStorage
->addTermPermissionsByUserIds([
99,
], $term
->id());
$node = Node::create([
'type' => 'page',
'title' => 'test_title',
'field_tags' => [
[
'target_id' => $tids[0],
],
[
'target_id' => $tids[1],
],
],
'field_tags2' => [
[
'target_id' => $tids[2],
],
],
]);
$node
->save();
$this
->setNidOneGrantedTerm($node
->id());
}