function CommentUninstallTest::testCommentUninstallWithoutField in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentUninstallTest.php \Drupal\comment\Tests\CommentUninstallTest::testCommentUninstallWithoutField()
Tests if uninstallation succeeds if the field has been deleted beforehand.
File
- core/
modules/ comment/ src/ Tests/ CommentUninstallTest.php, line 63 - Contains \Drupal\comment\Tests\CommentUninstallTest.
Class
- CommentUninstallTest
- Tests comment module uninstallation.
Namespace
Drupal\comment\TestsCode
function testCommentUninstallWithoutField() {
// Manually delete the comment_body field before module uninstallation.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this
->assertNotNull($field_storage, 'The comment_body field exists.');
$field_storage
->delete();
// Check that the field is now deleted.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this
->assertNull($field_storage, 'The comment_body field has been deleted.');
// Manually delete the comment field on the node before module uninstallation.
$field_storage = FieldStorageConfig::loadByName('node', 'comment');
$this
->assertNotNull($field_storage, 'The comment field exists.');
$field_storage
->delete();
// Check that the field is now deleted.
$field_storage = FieldStorageConfig::loadByName('node', 'comment');
$this
->assertNull($field_storage, 'The comment field has been deleted.');
field_purge_batch(10);
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
$this->container
->get('module_installer')
->uninstall(array(
'comment',
));
}