Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/tests/fixtures/update/drupal-8.views-taxonomy-parent-2543726.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Contains database additions to drupal-8.bare.standard.php.gz for testing the | |
6 * upgrade path of https://www.drupal.org/node/2455125. | |
7 */ | |
8 | |
9 use Drupal\Component\Uuid\Php; | |
10 use Drupal\Core\Database\Database; | |
11 use Drupal\Core\Serialization\Yaml; | |
12 | |
13 $connection = Database::getConnection(); | |
14 | |
15 $view_file = __DIR__ . '/drupal-8.views-taxonomy-parent-2543726.yml'; | |
16 $view_config = Yaml::decode(file_get_contents($view_file)); | |
17 | |
18 $connection->insert('config') | |
19 ->fields(['collection', 'name', 'data']) | |
20 ->values([ | |
21 'collection' => '', | |
22 'name' => "views.view.test_taxonomy_parent", | |
23 'data' => serialize($view_config), | |
24 ]) | |
25 ->execute(); | |
26 | |
27 $uuid = new Php(); | |
28 | |
29 // The root tid. | |
30 $tids = [0]; | |
31 | |
32 for ($i = 0; $i < 4; $i++) { | |
33 $name = $this->randomString(); | |
34 | |
35 $tid = $connection->insert('taxonomy_term_data') | |
36 ->fields(['vid', 'uuid', 'langcode']) | |
37 ->values(['vid' => 'tags', 'uuid' => $uuid->generate(), 'langcode' => 'en']) | |
38 ->execute(); | |
39 | |
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]) | |
43 ->execute(); | |
44 | |
45 $tids[] = $tid; | |
46 } | |
47 | |
48 $hierarchy = [ | |
49 // Term with tid 1 has terms with tids 2 and 3 as parents. | |
50 1 => [2, 3], | |
51 2 => [3, 0], | |
52 3 => [0], | |
53 ]; | |
54 | |
55 $query = $connection->insert('taxonomy_term_hierarchy')->fields(['tid', 'parent']); | |
56 | |
57 foreach ($hierarchy as $tid => $parents) { | |
58 foreach ($parents as $parent) { | |
59 $query->values(['tid' => $tids[$tid], 'parent' => $tids[$parent]]); | |
60 } | |
61 } | |
62 | |
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]); | |
66 | |
67 $query->execute(); |