Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / RecalculatedDependencyTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests system_post_update_recalculate_dependencies_for_installed_config_entities().
9  *
10  * @group Update
11  * @group legacy
12  */
13 class RecalculatedDependencyTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
21     ];
22   }
23
24   /**
25    * Ensures that the entities are resaved so they have the new dependency.
26    */
27   public function testUpdate() {
28     // Test the configuration pre update.
29     $data = \Drupal::config('field.field.node.article.field_tags')->get();
30     $this->assertEqual(['entity_reference'], $data['dependencies']['module']);
31     $this->assertEqual([
32       'field.storage.node.field_tags',
33       'node.type.article',
34     ], $data['dependencies']['config']);
35
36     $data = \Drupal::config('field.field.user.user.user_picture')->get();
37     $this->assertFalse(isset($data['dependencies']['module']));
38
39     $data = \Drupal::config('field.storage.node.field_image')->get();
40     $this->assertEqual(['node', 'image'], $data['dependencies']['module']);
41
42     // Explicitly break an optional configuration dependencies to ensure it is
43     // recalculated. Use active configuration storage directly so that no events
44     // are fired.
45     $config_storage = \Drupal::service('config.storage');
46     $data = $config_storage->read('search.page.node_search');
47     unset($data['dependencies']);
48     $config_storage->write('search.page.node_search', $data);
49     // Ensure the update is successful.
50     $data = \Drupal::config('search.page.node_search')->get();
51     $this->assertFalse(isset($data['dependencies']['module']));
52
53     // Run the updates.
54     $this->runUpdates();
55
56     // Test the configuration post update.
57     $data = \Drupal::config('field.field.node.article.field_tags')->get();
58     $this->assertFalse(isset($data['dependencies']['module']));
59     $this->assertEqual([
60       'field.storage.node.field_tags',
61       'node.type.article',
62       'taxonomy.vocabulary.tags',
63     ], $data['dependencies']['config']);
64
65     $data = \Drupal::config('field.field.user.user.user_picture')->get();
66     $this->assertEqual(['image', 'user'], $data['dependencies']['module']);
67
68     $data = \Drupal::config('field.storage.node.field_image')->get();
69     $this->assertEqual(['file', 'image', 'node'], $data['dependencies']['module']);
70
71     $data = \Drupal::config('search.page.node_search')->get();
72     $this->assertEqual(['node'], $data['dependencies']['module']);
73   }
74
75 }