function VocabularyCrudTest::testUninstallReinstall in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Tests/VocabularyCrudTest.php \Drupal\taxonomy\Tests\VocabularyCrudTest::testUninstallReinstall()
Test uninstall and reinstall of the taxonomy module.
File
- core/
modules/ taxonomy/ src/ Tests/ VocabularyCrudTest.php, line 147 - Contains \Drupal\taxonomy\Tests\VocabularyCrudTest.
Class
- VocabularyCrudTest
- Tests loading, saving and deleting vocabularies.
Namespace
Drupal\taxonomy\TestsCode
function testUninstallReinstall() {
// Field storages and fields attached to taxonomy term bundles should be
// removed when the module is uninstalled.
$field_name = Unicode::strtolower($this
->randomMachineName() . '_field_name');
$storage_definition = array(
'field_name' => $field_name,
'entity_type' => 'taxonomy_term',
'type' => 'text',
'cardinality' => 4,
);
entity_create('field_storage_config', $storage_definition)
->save();
$field_definition = array(
'field_name' => $field_name,
'entity_type' => 'taxonomy_term',
'bundle' => $this->vocabulary
->id(),
'label' => $this
->randomMachineName() . '_label',
);
entity_create('field_config', $field_definition)
->save();
// Remove the third party setting from the memory copy of the vocabulary.
// We keep this invalid copy around while the taxonomy module is not even
// installed for testing below.
$this->vocabulary
->unsetThirdPartySetting('taxonomy_crud', 'foo');
require_once \Drupal::root() . '/core/includes/install.inc';
$this->container
->get('module_installer')
->uninstall(array(
'taxonomy',
));
$this->container
->get('module_installer')
->install(array(
'taxonomy',
));
// Now create a vocabulary with the same name. All fields
// connected to this vocabulary name should have been removed when the
// module was uninstalled. Creating a new field with the same name and
// an instance of this field on the same bundle name should be successful.
$this->vocabulary
->enforceIsNew();
$this->vocabulary
->save();
entity_create('field_storage_config', $storage_definition)
->save();
entity_create('field_config', $field_definition)
->save();
}