protected function HierarchicalTaxonomyMenuDynamicTest::setUp in Hierarchical Taxonomy Menu 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ FunctionalJavascript/ HierarchicalTaxonomyMenuDynamicTest.php, line 61
Class
- HierarchicalTaxonomyMenuDynamicTest
- Tests the Hierarchical Taxonomy Menu dynamic behaviour.
Namespace
Drupal\Tests\hierarchical_taxonomy_menu\FunctionalJavascriptCode
protected function setUp() {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'administer blocks',
'administer site configuration',
'access administration pages',
]);
$this
->drupalLogin($admin_user);
$this->vocabulary = $this
->createVocabulary();
// Generate taxonomy tree with 3 parents. Each parent has 11 descendants.
// @codingStandardsIgnoreStart
// Parent term 1 (Term ID: 1)
// Child term 1-1 (Term ID: 2)
// Child term 1-2 (Term ID: 3)
// Child term 1-3 (Term ID: 4)
// Child term 1-4 (Term ID: 5)
// Child term 1-5 (Term ID: 6)
// Child term 1-6 (Term ID: 7)
// Child term 1-7 (Term ID: 8)
// Child term 1-8 (Term ID: 9)
// Child term 1-9 (Term ID: 10)
// Child term 1-10 (Term ID: 11)
// Child term 1-11 (Term ID: 12)
// Parent term 2 (Term ID: 13)
// Child term 2-1 (Term ID: 14)
// Child term 2-2 (Term ID: 15)
// Child term 2-3 (Term ID: 16)
// Child term 2-4 (Term ID: 17)
// Child term 2-5 (Term ID: 18)
// Child term 2-6 (Term ID: 19)
// Child term 2-7 (Term ID: 20)
// Child term 2-8 (Term ID: 21)
// Child term 2-9 (Term ID: 22)
// Child term 2-10 (Term ID: 23)
// Child term 2-11 (Term ID: 24)
// Parent term 3 (Term ID: 25)
// Child term 3-1 (Term ID: 26)
// Child term 3-2 (Term ID: 27)
// Child term 3-3 (Term ID: 28)
// Child term 3-4 (Term ID: 29)
// Child term 3-5 (Term ID: 30)
// Child term 3-6 (Term ID: 31)
// Child term 3-7 (Term ID: 32)
// Child term 3-8 (Term ID: 33)
// Child term 3-9 (Term ID: 34)
// Child term 3-10 (Term ID: 35)
// Child term 3-11 (Term ID: 36)
// @codingStandardsIgnoreEnd
for ($i = 1; $i < 4; $i++) {
$parent = Term::create([
'vid' => $this->vocabulary
->id(),
'name' => 'Parent term ' . $i,
]);
$parent
->save();
for ($n = 1; $n < 12; $n++) {
$child = Term::create([
'vid' => $this->vocabulary
->id(),
'name' => 'Child term ' . $i . '-' . $n,
]);
if ($n == 1) {
$child->parent = $parent
->id();
}
else {
$child->parent = $this->childParent;
}
$child
->save();
$this->childParent = $child
->id();
}
}
$this->block = $this
->drupalPlaceBlock('hierarchical_taxonomy_menu', [
'region' => 'content',
'label' => 'Hierarchical Taxonomy Menu',
'id' => 'hierarchicaltaxonomymenu',
]);
}