updateEntityTypeToRevisionable example


    }
  }

  /** * Tests that views are disabled when an entity type is deleted. */
  public function testDeleteEntityType() {
    $entity_storage = $this->entityTypeManager->getStorage('view');

    // Make the test entity type revisionable.     $this->updateEntityTypeToRevisionable(TRUE);

    $views = $entity_storage->loadMultiple();

    // Ensure that all test views exists.     $this->assertTrue(isset($views['test_view_entity_test']));
    $this->assertTrue(isset($views['test_view_entity_test_revision']));
    $this->assertTrue(isset($views['test_view_entity_test_data']));
    $this->assertTrue(isset($views['test_view_entity_test_additional_base_field']));

    $event = new EntityTypeEvent($this->entityTypeManager->getDefinition('entity_test_update'));
    $this->eventDispatcher->dispatch($event, EntityTypeEvents::DELETE);

    
/** * Tests updating entity schema when there are no existing entities. */
  public function testEntityTypeUpdateWithoutData() {
    // The 'entity_test_update' entity type starts out non-revisionable, so     // ensure the revision table hasn't been created during setUp().     $this->assertFalse($this->database->schema()->tableExists('entity_test_update_revision'), 'Revision table not created for entity_test_update.');

    // Update it to be revisionable and ensure the definition update manager     // reports that an update is needed.     $this->updateEntityTypeToRevisionable();
    $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
    $expected = [
      'entity_test_update' => [
        t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityTypeManager->getDefinition('entity_test_update')->getLabel()]),
        // The revision key is now defined, so the revision field needs to be         // created.         t('The %field_name field needs to be installed.', ['%field_name' => 'Revision ID']),
        t('The %field_name field needs to be installed.', ['%field_name' => 'Default revision']),
      ],
    ];
    $this->assertEquals($expected$this->entityDefinitionUpdateManager->getChangeSummary(), 'EntityDefinitionUpdateManager reports the expected change summary.');

    
Home | Imprint | This part of the site doesn't use cookies.