Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / EntityUpdateAddRevisionTranslationAffectedTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\system\Tests\Entity\EntityDefinitionTestTrait;
7
8 /**
9  * Tests the upgrade path for adding the 'revision_translation_affected' field.
10  *
11  * @see https://www.drupal.org/node/2896845
12  *
13  * @group Update
14  */
15 class EntityUpdateAddRevisionTranslationAffectedTest extends UpdatePathTestBase {
16
17   use EntityDefinitionTestTrait;
18   use DbUpdatesTrait;
19
20   /**
21    * The entity manager service.
22    *
23    * @var \Drupal\Core\Entity\EntityManagerInterface
24    */
25   protected $entityManager;
26
27   /**
28    * The last installed schema repository service.
29    *
30    * @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface
31    */
32   protected $lastInstalledSchemaRepository;
33
34   /**
35    * The state service.
36    *
37    * @var \Drupal\Core\State\StateInterface
38    */
39   protected $state;
40
41   /**
42    * {@inheritdoc}
43    */
44   protected function setUp() {
45     parent::setUp();
46
47     $this->entityManager = \Drupal::entityManager();
48     $this->lastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository');
49     $this->state = \Drupal::state();
50   }
51
52   /**
53    * {@inheritdoc}
54    */
55   protected function setDatabaseDumpFiles() {
56     $this->databaseDumpFiles = [
57       __DIR__ . '/../../../fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul_rev.php.gz',
58     ];
59   }
60
61   /**
62    * Tests the addition of the 'revision_translation_affected' base field.
63    *
64    * @see system_update_8402()
65    */
66   public function testAddingTheRevisionTranslationAffectedField() {
67     // Make the entity type revisionable and translatable prior to running the
68     // updates.
69     $this->updateEntityTypeToRevisionableAndTranslatable();
70
71     // Check that the test entity type does not have the
72     // 'revision_translation_affected' field before running the updates.
73     $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update');
74     $this->assertFalse(isset($field_storage_definitions['revision_translation_affected']));
75
76     $this->runUpdates();
77
78     // Check that the 'revision_translation_affected' field has been added by
79     // system_update_8402().
80     $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update');
81     $this->assertTrue(isset($field_storage_definitions['revision_translation_affected']));
82
83     // Check that the correct initial value was set when the field was
84     // installed.
85     $entity = $this->entityManager->getStorage('entity_test_update')->load(1);
86     $this->assertTrue($entity->revision_translation_affected->value);
87   }
88
89 }