function CommentUninstallTest::testCommentUninstallWithField in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentUninstallTest.php \Drupal\comment\Tests\CommentUninstallTest::testCommentUninstallWithField()
Tests if comment module uninstallation fails if the field exists.
Throws
\Drupal\Core\Extension\ModuleUninstallValidatorException
File
- core/
modules/ comment/ src/ Tests/ CommentUninstallTest.php, line 44 - Contains \Drupal\comment\Tests\CommentUninstallTest.
Class
- CommentUninstallTest
- Tests comment module uninstallation.
Namespace
Drupal\comment\TestsCode
function testCommentUninstallWithField() {
// Ensure that the field exists before uninstallation.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this
->assertNotNull($field_storage, 'The comment_body field exists.');
// Uninstall the comment module which should trigger an exception.
try {
$this->container
->get('module_installer')
->uninstall(array(
'comment',
));
$this
->fail("Expected an exception when uninstall was attempted.");
} catch (ModuleUninstallValidatorException $e) {
$this
->pass("Caught an exception when uninstall was attempted.");
}
}