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 / ConfigOverridesUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests system_update_8200().
9  *
10  * @see system_update_8200()
11  *
12  * @group Update
13  * @group legacy
14  */
15 class ConfigOverridesUpdateTest extends UpdatePathTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function setDatabaseDumpFiles() {
21     $this->databaseDumpFiles = [
22       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.filled.standard.php.gz',
23       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.config-override-fix.php',
24     ];
25   }
26
27   /**
28    * Tests that configuration has been updated.
29    */
30   public function testUpdatedSite() {
31     $key_to_be_removed = 'display.default.display_options.fields.nid';
32     /** @var \Drupal\Core\Config\Config $config_override */
33     $language_config_override = \Drupal::service('language.config_factory_override');
34     $config_override = $language_config_override->getOverride('es', 'views.view.content');
35     $this->assertEqual('Spanish ID', $config_override->get($key_to_be_removed)['label'], 'The spanish override for the missing field exists before updating.');
36     // Since the above view will be fixed by other updates that fix views
37     // configuration for example,
38     // views_post_update_update_cacheability_metadata(), also test configuration
39     // that has yet to be modified in an update path.
40     $config_override = $language_config_override->getOverride('es', 'system.cron');
41     $this->assertEqual('Should be cleaned by system_update_8200', $config_override->get('bogus_key'), 'The spanish override in system.cron exists before updating.');
42
43     $this->runUpdates();
44
45     /** @var \Drupal\Core\Config\Config $config_override */
46     $config_override = \Drupal::service('language.config_factory_override')->getOverride('es', 'views.view.content');
47     $this->assertNull($config_override->get($key_to_be_removed), 'The spanish override for the missing field has been removed.');
48     $config_override = $language_config_override->getOverride('es', 'system.cron');
49     $this->assertTrue($config_override->isNew(), 'After updating the system.cron spanish override does not exist.');
50     $this->assertTrue(empty($config_override->get()), 'After updating the system.cron spanish override has no data.');
51
52     // Test that the spanish overrides still work.
53     $this->drupalLogin($this->createUser(['access content overview']));
54     $this->drupalGet('admin/content', ['language' => \Drupal::languageManager()->getLanguage('es')]);
55     $this->assertText('Spanish Title');
56     $this->assertText('Spanish Author');
57   }
58
59 }