Skip to content
Snippets Groups Projects

Issue #2928661 by kriboogh: Reordering taxonomy terms after "Reset to...

Issue #2928661 by kriboogh: Reordering taxonomy terms after "Reset to alphabetical" yields incorrect results upon save

Merged fixes by capysara from 10.1 into 11.x

Closes #2928661

Merge request reports

Members who can merge are allowed to add commits.

Merged result pipeline #261025 passed

Merged result pipeline passed for 035f9995

Approval is optional
Ready to merge by members who can write to the target branch.
  • The source branch is 484 commits behind the target branch.
  • 1 commit will be added to 11.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
70 71 if (empty($values['parent'])) {
71 72 $values['parent'] = [0];
72 73 }
74
  • 84 87 $this->treeTerms = [];
    85 88 $this->trees = [];
    86 89 $this->vocabularyHierarchyType = [];
    90
  • 92 96 */
    93 97 public function loadParents($tid) {
    94 98 $terms = [];
    99
  • 208 215 */
    209 216 public function loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE) {
    210 217 $cache_key = implode(':', func_get_args());
    218
  • 26 protected $defaultTheme = 'stark';
    27
    28 /**
    29 * {@inheritdoc}
    30 */
    31 protected function setUp(): void {
    32 parent::setUp();
    33
    34 $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
    35 $this->vocabulary = $this->createVocabulary();
    36 }
    37
    38 /**
    39 * Change order of terms & update a term using the user interface.
    40 */
    41 public function testTermReorderAndUpdate() {
  • 200 $this->assertWeightOnForm('0', '0', '1', '3');
    201 }
    202
    203 /**
    204 * Helper function to assert order on Overview Form UI.
    205 *
    206 * @param string $first
    207 * Name of term expected in first row.
    208 * @param string $second
    209 * Name of term expected in second row.
    210 * @param string $third
    211 * Name of term expected in third row.
    212 * @param string $fourth
    213 * Name of term expected in fourth row.
    214 */
    215 protected function assertOrderOnForm(string $first, string $second, string $third, string $fourth) {
  • 220 $this->assertSame($fourth, $page->find('css', '#taxonomy tbody tr:nth-child(4) a[id^="edit-terms"]')->getText());
    221 }
    222
    223 /**
    224 * Helper function to assert weights on Overview Form UI.
    225 *
    226 * @param string $first
    227 * Weight of term expected in first row.
    228 * @param string $second
    229 * Weight of term expected in second row.
    230 * @param string $third
    231 * Weight of term expected in third row.
    232 * @param string $fourth
    233 * Weight of term expected in fourth row.
    234 */
    235 protected function assertWeightOnForm(string $first, string $second, string $third, string $fourth) {
  • 282 $this->assertSame($fourth, $tree[3]->getName());
    283 }
    284
    285 /**
    286 * Helper function to assert parents in loaded tree.
    287 *
    288 * @param string $first
    289 * TID of term expected as parent of first term.
    290 * @param string $second
    291 * TID of term expected as parent of second term.
    292 * @param string $third
    293 * TID of term expected as parent of third term.
    294 * @param string $fourth
    295 * TID of term expected as parent of fourth term.
    296 */
    297 protected function assertParentsInTree(string $first, string $second, string $third, string $fourth) {
  • 260 $this->assertCount($fourth, $page->findAll('css', '#taxonomy tbody tr:nth-child(4) .indentation'));
    261 }
    262
    263 /**
    264 * Helper function to assert order in loaded tree.
    265 *
    266 * @param string $first
    267 * Name of term expected first.
    268 * @param string $second
    269 * Name of term expected second.
    270 * @param string $third
    271 * Name of term expected third.
    272 * @param string $fourth
    273 * Name of term expected fourth.
    274 */
    275 protected function assertOrderInTree(string $first, string $second, string $third, string $fourth) {
  • 240 $this->assertSame($fourth, $page->find('css', '#taxonomy tbody tr:nth-child(4) .term-weight')->getValue());
    241 }
    242
    243 /**
    244 * Helper function to assert indentation on Overview Form UI.
    245 *
    246 * @param int $first
    247 * Indentation expected in first row.
    248 * @param int $second
    249 * Indentation expected in second row.
    250 * @param int $third
    251 * Indentation expected in third row.
    252 * @param int $fourth
    253 * Indentation expected in fourth row.
    254 */
    255 protected function assertIndentationOnForm(int $first, int $second, int $third, int $fourth) {
  • 117 // Drag first row (Alpha 2) to the bottom row.
    118 $first_handle = $page->find('css', '#taxonomy tbody tr:nth-child(1) .tabledrag-handle');
    119 $last_handle = $page->find('css', '#taxonomy tbody tr:nth-child(4) .tabledrag-handle');
    120 $first_handle->dragTo($last_handle);
    121 $page->pressButton('Save');
    122
    123 // Form should reload with this order:
    124 // Bravo 1, Charlie 4, Delta 3, Alpha 2.
    125 $this->assertOrderOnForm('Bravo 1', 'Charlie 4', 'Delta 3', 'Alpha 2');
    126 $this->assertOrderInTree('Bravo 1', 'Charlie 4', 'Delta 3', 'Alpha 2');
    127 }
    128
    129 /**
    130 * Test nesting and moving terms using the form.
    131 */
    132 public function testTermNesting() {
  • 1 <?php
  • 70 71 if (empty($values['parent'])) {
    71 72 $values['parent'] = [0];
    72 73 }
    74
  • 84 87 $this->treeTerms = [];
    85 88 $this->trees = [];
    86 89 $this->vocabularyHierarchyType = [];
    90
  • 92 96 */
    93 97 public function loadParents($tid) {
    94 98 $terms = [];
    99
  • 208 215 */
    209 216 public function loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE) {
    210 217 $cache_key = implode(':', func_get_args());
    218
  • added 1 commit

    • 67103670 - Updated spacing issues and added return types.

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading