3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\system\Tests\Entity\EntityDefinitionTestTrait;
9 * Tests the upgrade path for adding the 'revision_translation_affected' field.
11 * @see https://www.drupal.org/node/2896845
15 class EntityUpdateAddRevisionTranslationAffectedTest extends UpdatePathTestBase {
17 use EntityDefinitionTestTrait;
21 * The entity manager service.
23 * @var \Drupal\Core\Entity\EntityManagerInterface
25 protected $entityManager;
28 * The last installed schema repository service.
30 * @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface
32 protected $lastInstalledSchemaRepository;
37 * @var \Drupal\Core\State\StateInterface
44 protected function setUp() {
47 $this->entityManager = \Drupal::entityManager();
48 $this->lastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository');
49 $this->state = \Drupal::state();
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',
62 * Tests the addition of the 'revision_translation_affected' base field.
64 * @see system_update_8402()
66 public function testAddingTheRevisionTranslationAffectedField() {
67 // Make the entity type revisionable and translatable prior to running the
69 $this->updateEntityTypeToRevisionableAndTranslatable();
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']));
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']));
83 // Check that the correct initial value was set when the field was
85 $entity = $this->entityManager->getStorage('entity_test_update')->load(1);
86 $this->assertTrue($entity->revision_translation_affected->value);