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