public function CommentUninstallTest::testCommentUninstallWithField in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Kernel/CommentUninstallTest.php \Drupal\Tests\comment\Kernel\CommentUninstallTest::testCommentUninstallWithField()
- 10 core/modules/comment/tests/src/Kernel/CommentUninstallTest.php \Drupal\Tests\comment\Kernel\CommentUninstallTest::testCommentUninstallWithField()
Tests if comment module uninstall fails if the field exists.
File
- core/
modules/ comment/ tests/ src/ Kernel/ CommentUninstallTest.php, line 56
Class
- CommentUninstallTest
- Tests comment module uninstall.
Namespace
Drupal\Tests\comment\KernelCode
public function testCommentUninstallWithField() {
// Ensure that the field exists before uninstalling.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this
->assertNotNull($field_storage);
// Uninstall the comment module which should trigger an exception.
$this
->expectException(ModuleUninstallValidatorException::class);
$this
->expectExceptionMessage('The following reasons prevent the modules from being uninstalled: The <em class="placeholder">Comments</em> field type is used in the following field: node.comment');
$this->container
->get('module_installer')
->uninstall([
'comment',
]);
}