Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / UpdatePathRC1TestBaseTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\Component\Render\FormattableMarkup;
6 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
7
8 /**
9  * Tests the update path base class with the RC1 database dump.
10  *
11  * @group Update
12  * @group legacy
13  */
14 class UpdatePathRC1TestBaseTest extends UpdatePathTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   protected static $modules = ['update_test_schema'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setDatabaseDumpFiles() {
25     $this->databaseDumpFiles = [
26       __DIR__ . '/../../../../tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
27     ];
28   }
29
30   /**
31    * Tests that the database was properly loaded.
32    */
33   public function testDatabaseLoaded() {
34     $extensions = \Drupal::service('config.storage')->read('core.extension');
35     $this->assertFalse(isset($extensions['theme']['stable']), 'Stable is not installed before updating.');
36     $hook_updates = [
37       'user' => '8000',
38       'node' => '8003',
39       'system' => '8013',
40     ];
41     foreach ($hook_updates as $module => $schema) {
42       $this->assertEqual(drupal_get_installed_schema_version($module), $schema, new FormattableMarkup('Module @module schema is @schema', ['@module' => $module, '@schema' => $schema]));
43     }
44
45     // Test post_update key value stores contains a list of the update functions
46     // that have run.
47     $existing_updates = array_count_values(\Drupal::keyValue('post_update')->get('existing_updates'));
48     $expected_updates = [
49       'system_post_update_recalculate_configuration_entity_dependencies',
50       'field_post_update_save_custom_storage_property',
51       'field_post_update_entity_reference_handler_setting',
52       'block_post_update_disable_blocks_with_missing_contexts',
53       'views_post_update_update_cacheability_metadata',
54     ];
55     foreach ($expected_updates as $expected_update) {
56       $this->assertEqual($existing_updates[$expected_update], 1, new FormattableMarkup("@expected_update exists in 'existing_updates' key and only appears once.", ['@expected_update' => $expected_update]));
57     }
58
59     $this->runUpdates();
60     $this->assertEqual(\Drupal::config('system.site')->get('name'), 'Site-Install');
61     $this->drupalGet('<front>');
62     $this->assertText('Site-Install');
63     $extensions = \Drupal::service('config.storage')->read('core.extension');
64     $this->assertTrue(isset($extensions['theme']['stable']), 'Stable is installed after updating.');
65     $blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => 'stable']);
66     $this->assertTrue(empty($blocks), 'No blocks have been placed for Stable.');
67   }
68
69 }