3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait;
9 * Tests the upgrade path for adding the 'revision_translation_affected' field.
11 * @see https://www.drupal.org/node/2896845
16 class EntityUpdateAddRevisionTranslationAffectedTest extends UpdatePathTestBase {
18 use EntityDefinitionTestTrait;
22 * The entity manager service.
24 * @var \Drupal\Core\Entity\EntityManagerInterface
26 protected $entityManager;
29 * The last installed schema repository service.
31 * @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface
33 protected $lastInstalledSchemaRepository;
38 * @var \Drupal\Core\State\StateInterface
45 protected function setUp() {
48 $this->entityManager = \Drupal::entityManager();
49 $this->lastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository');
50 $this->state = \Drupal::state();
56 protected function setDatabaseDumpFiles() {
57 $this->databaseDumpFiles = [
58 __DIR__ . '/../../../fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul_rev.php.gz',
63 * Tests the addition of the 'revision_translation_affected' base field.
65 * @see system_update_8402()
67 public function testAddingTheRevisionTranslationAffectedField() {
68 // Make the entity type revisionable and translatable prior to running the
70 $this->updateEntityTypeToRevisionableAndTranslatable();
72 // Check that the test entity type does not have the
73 // 'revision_translation_affected' field before running the updates.
74 $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update');
75 $this->assertFalse(isset($field_storage_definitions['revision_translation_affected']));
79 // Check that the 'revision_translation_affected' field has been added by
80 // system_update_8402().
81 $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update');
82 $this->assertTrue(isset($field_storage_definitions['revision_translation_affected']));
84 // Check that the correct initial value was set when the field was
86 $entity = $this->entityManager->getStorage('entity_test_update')->load(1);
87 $this->assertTrue($entity->revision_translation_affected->value);