X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FFunctional%2FUpdate%2FEntityUpdateAddRevisionDefaultTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FFunctional%2FUpdate%2FEntityUpdateAddRevisionDefaultTest.php;h=e226540b6ae63bab036ff357f269c0fbce1b2c3d;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionDefaultTest.php b/web/core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionDefaultTest.php new file mode 100644 index 000000000..e226540b6 --- /dev/null +++ b/web/core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionDefaultTest.php @@ -0,0 +1,90 @@ +entityManager = \Drupal::entityManager(); + $this->lastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository'); + $this->state = \Drupal::state(); + } + + /** + * {@inheritdoc} + */ + protected function setDatabaseDumpFiles() { + $this->databaseDumpFiles = [ + __DIR__ . '/../../../fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul_rev.php.gz', + ]; + } + + /** + * Tests the addition of the 'revision_default' base field. + * + * @see system_update_8501() + */ + public function testAddingTheRevisionDefaultField() { + // Make the entity type revisionable and translatable prior to running the + // updates. + $this->updateEntityTypeToRevisionableAndTranslatable(); + + // Check that the test entity type does not have the 'revision_default' + // field before running the updates. + $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update'); + $this->assertFalse(isset($field_storage_definitions['revision_default'])); + + $this->runUpdates(); + + // Check that the 'revision_default' field has been added by + // system_update_8501(). + $field_storage_definitions = $this->lastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions('entity_test_update'); + $this->assertTrue(isset($field_storage_definitions['revision_default'])); + + // Check that the correct initial value was set when the field was + // installed. + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ + $entity = $this->entityManager->getStorage('entity_test_update')->load(1); + $this->assertTrue($entity->wasDefaultRevision()); + } + +}