private function MultilingualTest::setupEntities in Permissions by Term 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/MultilingualTest.php \Drupal\Tests\permissions_by_term\Kernel\MultilingualTest::setupEntities()
1 call to MultilingualTest::setupEntities()
- MultilingualTest::testCanNotAccess in tests/
src/ Kernel/ MultilingualTest.php
File
- tests/
src/ Kernel/ MultilingualTest.php, line 79
Class
- MultilingualTest
- @group permissions_by_term
Namespace
Drupal\Tests\permissions_by_term\KernelCode
private function setupEntities() {
$i = 0;
foreach ([
'de',
] as $langcode) {
$language = ConfigurableLanguage::createFromLangcode($langcode);
$language
->set('weight', $i--);
$language
->save();
}
Vocabulary::create([
'name' => 'Test English',
'vid' => 'test_multilingual_en',
'langcode' => 'en',
])
->save();
Vocabulary::create([
'name' => 'Test German',
'vid' => 'test_multilingual_de',
'langcode' => 'de',
])
->save();
$term = Term::create([
'name' => 'term1',
'vid' => 'test_multilingual_en',
'langcode' => 'en',
]);
$term
->save();
$node = Node::create([
'type' => 'page',
'title' => 'test_title',
'field_tags' => [
[
'target_id' => $term
->id(),
],
],
]);
$node
->save();
$termDe = Term::create([
'name' => 'term DE',
'vid' => 'test_multilingual_de',
'langcode' => 'de',
]);
$termDe
->save();
$nodeDe = $node
->addTranslation('de');
$nodeDe->title = 'Node Übersetzung';
$nodeDe->field_tags = [
[
'target_id' => $termDe
->id(),
],
];
$nodeDe
->save();
$user = User::create([
'name' => 'some_username123',
'status' => 1,
]);
$user
->save();
return [
$termDe,
$nodeDe,
$term,
$node,
$user,
];
}