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