X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Ffixtures%2Fupdate%2Fdrupal-8.views-taxonomy-parent-2543726.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Ffixtures%2Fupdate%2Fdrupal-8.views-taxonomy-parent-2543726.php;h=6d2c41c56e192e33b5c9bc3a9511787518a0e9a0;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/system/tests/fixtures/update/drupal-8.views-taxonomy-parent-2543726.php b/web/core/modules/system/tests/fixtures/update/drupal-8.views-taxonomy-parent-2543726.php new file mode 100644 index 000000000..6d2c41c56 --- /dev/null +++ b/web/core/modules/system/tests/fixtures/update/drupal-8.views-taxonomy-parent-2543726.php @@ -0,0 +1,67 @@ +insert('config') + ->fields(['collection', 'name', 'data']) + ->values([ + 'collection' => '', + 'name' => "views.view.test_taxonomy_parent", + 'data' => serialize($view_config), + ]) + ->execute(); + +$uuid = new Php(); + +// The root tid. +$tids = [0]; + +for ($i = 0; $i < 4; $i++) { + $name = $this->randomString(); + + $tid = $connection->insert('taxonomy_term_data') + ->fields(['vid', 'uuid', 'langcode']) + ->values(['vid' => 'tags', 'uuid' => $uuid->generate(), 'langcode' => 'en']) + ->execute(); + + $connection->insert('taxonomy_term_field_data') + ->fields(['tid', 'vid', 'langcode', 'name', 'weight', 'changed', 'default_langcode']) + ->values(['tid' => $tid, 'vid' => 'tags', 'langcode' => 'en', 'name' => $name, 'weight' => 0, 'changed' => REQUEST_TIME, 'default_langcode' => 1]) + ->execute(); + + $tids[] = $tid; +} + +$hierarchy = [ + // Term with tid 1 has terms with tids 2 and 3 as parents. + 1 => [2, 3], + 2 => [3, 0], + 3 => [0], +]; + +$query = $connection->insert('taxonomy_term_hierarchy')->fields(['tid', 'parent']); + +foreach ($hierarchy as $tid => $parents) { + foreach ($parents as $parent) { + $query->values(['tid' => $tids[$tid], 'parent' => $tids[$parent]]); + } +} + +// Insert an extra record with no corresponding term. +// See https://www.drupal.org/project/drupal/issues/2997982 +$query->values(['tid' => max($tids) + 1, 'parent' => 0]); + +$query->execute();