408493f90487fda527892755ee9b6676ecb9c8a2
[yaffs-website] / web / core / modules / system / tests / src / Functional / Entity / Update / SqlContentEntityStorageSchemaIndexTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Entity\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests that a newly-added index is properly created during database updates.
9  *
10  * @group Entity
11  * @group legacy
12  */
13 class SqlContentEntityStorageSchemaIndexTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../fixtures/update/drupal-8.bare.standard.php.gz',
21     ];
22   }
23
24   /**
25    * Tests entity and field schema database updates and execution order.
26    */
27   public function testIndex() {
28     // The initial Drupal 8 database dump before any updates does not include
29     // the entity ID in the entity field data table indices that were added in
30     // https://www.drupal.org/node/2261669.
31     $this->assertTrue(db_index_exists('node_field_data', 'node__default_langcode'), 'Index node__default_langcode exists prior to running updates.');
32     $this->assertFalse(db_index_exists('node_field_data', 'node__id__default_langcode__langcode'), 'Index node__id__default_langcode__langcode does not exist prior to running updates.');
33     $this->assertFalse(db_index_exists('users_field_data', 'user__id__default_langcode__langcode'), 'Index users__id__default_langcode__langcode does not exist prior to running updates.');
34
35     // Running database updates should update the entity schemata to add the
36     // indices from https://www.drupal.org/node/2261669.
37     $this->runUpdates();
38     $this->assertFalse(db_index_exists('node_field_data', 'node__default_langcode'), 'Index node__default_langcode properly removed.');
39     $this->assertTrue(db_index_exists('node_field_data', 'node__id__default_langcode__langcode'), 'Index node__id__default_langcode__langcode properly created on the node_field_data table.');
40     $this->assertTrue(db_index_exists('users_field_data', 'user__id__default_langcode__langcode'), 'Index users__id__default_langcode__langcode properly created on the user_field_data table.');
41   }
42
43 }