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