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