public function testTermReorder() { $assert =
$this->
assertSession();
$this->
createTerm($this->vocabulary
);
$this->
createTerm($this->vocabulary
);
$this->
createTerm($this->vocabulary
);
$taxonomy_storage =
$this->container->
get('entity_type.manager'
)->
getStorage('taxonomy_term'
);
// Fetch the created terms in the default alphabetical order, i.e. term1
// precedes term2 alphabetically, and term2 precedes term3.
$taxonomy_storage->
resetCache();
[$term1,
$term2,
$term3] =
$taxonomy_storage->
loadTree($this->vocabulary->
id(), 0, NULL, TRUE
);
$this->
drupalGet('admin/structure/taxonomy/manage/' .
$this->vocabulary->
id() . '/overview'
);
// Each term has four hidden fields, "tid:1:0[tid]", "tid:1:0[parent]",
// "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
// term3, term1 by setting weight property, make term3 a child of term2 by
// setting the parent and depth properties, and update all hidden fields.
$hidden_edit =
[ 'terms[tid:' .
$term2->
id() . ':0][term][tid]' =>
$term2->
id(),
'terms[tid:' .
$term2->
id() . ':0][term][parent]' => 0,