function EntityDefinitionUpdateTest::testUninstallEntityTypeWithoutInCodeDefinition

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testUninstallEntityTypeWithoutInCodeDefinition()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testUninstallEntityTypeWithoutInCodeDefinition()
  3. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testUninstallEntityTypeWithoutInCodeDefinition()

Tests uninstalling an entity type that doesn't exist in code anymore.

@covers ::uninstallEntityType

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php, line 241

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testUninstallEntityTypeWithoutInCodeDefinition() : void {
    $entity_type = clone $this->entityTypeManager
        ->getDefinition('entity_test_update');
    // Remove the entity type definition. This is the same thing as removing the
    // code that defines it.
    $this->deleteEntityType();
    // Now uninstall it and check that the tables have been removed.
    $this->assertTrue($this->database
        ->schema()
        ->tableExists('entity_test_update'), 'Base table for entity_test_update exists before uninstalling it.');
    $this->entityDefinitionUpdateManager
        ->uninstallEntityType($entity_type);
    $this->assertFalse($this->database
        ->schema()
        ->tableExists('entity_test_update'), 'Base table for entity_test_update does not exist anymore.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.