function CommentUninstallTest::testCommentUninstallWithField
Tests if comment module uninstall fails if the field exists.
File
- 
              core/modules/ comment/ tests/ src/ Kernel/ CommentUninstallTest.php, line 64 
Class
- CommentUninstallTest
- Tests comment module uninstall.
Namespace
Drupal\Tests\comment\KernelCode
public function testCommentUninstallWithField() : void {
  // 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',
  ]);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
