5 * Contains database additions to drupal-8.bare.standard.php.gz for testing the
6 * upgrade path of https://www.drupal.org/node/2455125.
9 use Drupal\Component\Uuid\Php;
10 use Drupal\Core\Database\Database;
11 use Drupal\Core\Serialization\Yaml;
13 $connection = Database::getConnection();
15 $view_file = __DIR__ . '/drupal-8.views-taxonomy-parent-2543726.yml';
16 $view_config = Yaml::decode(file_get_contents($view_file));
18 $connection->insert('config')
19 ->fields(['collection', 'name', 'data'])
22 'name' => "views.view.test_taxonomy_parent",
23 'data' => serialize($view_config),
32 for ($i = 0; $i < 4; $i++) {
33 $name = $this->randomString();
35 $tid = $connection->insert('taxonomy_term_data')
36 ->fields(['vid', 'uuid', 'langcode'])
37 ->values(['vid' => 'tags', 'uuid' => $uuid->generate(), 'langcode' => 'en'])
40 $connection->insert('taxonomy_term_field_data')
41 ->fields(['tid', 'vid', 'langcode', 'name', 'weight', 'changed', 'default_langcode'])
42 ->values(['tid' => $tid, 'vid' => 'tags', 'langcode' => 'en', 'name' => $name, 'weight' => 0, 'changed' => REQUEST_TIME, 'default_langcode' => 1])
49 // Term with tid 1 has terms with tids 2 and 3 as parents.
55 $query = $connection->insert('taxonomy_term_hierarchy')->fields(['tid', 'parent']);
57 foreach ($hierarchy as $tid => $parents) {
58 foreach ($parents as $parent) {
59 $query->values(['tid' => $tids[$tid], 'parent' => $tids[$parent]]);
63 // Insert an extra record with no corresponding term.
64 // See https://www.drupal.org/project/drupal/issues/2997982
65 $query->values(['tid' => max($tids) + 1, 'parent' => 0]);