diff --git a/core/modules/system/src/Tests/Module/InstallTest.php b/core/modules/system/src/Tests/Module/InstallTest.php
index 1068b60..38a804b 100644
--- a/core/modules/system/src/Tests/Module/InstallTest.php
+++ b/core/modules/system/src/Tests/Module/InstallTest.php
@@ -80,4 +80,34 @@ public function testModuleNameLength() {
     }
   }
 
+  /**
+   * Tests enabling a bugged module.
+   *
+   * The module to be enabled will produce a PHP SynatxError during install.
+   * It must not break the website.
+   */
+  public function testEnableBadModule() {
+
+    // Create and log as admin user.
+    $this->adminUser = $this->drupalCreateUser(array('administer modules'));
+    $this->drupalLogin($this->adminUser);
+
+    // Enable bad_module module.
+    $edit['modules[Testing][bad_module][enable]'] = TRUE;
+    $this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
+
+    // Check the syntax error occured.
+    $this->assertText("PHP syntax exception !");
+
+    // Check that the module is not enabled.
+    $this->drupalGet('admin/modules');
+    $this->assertNoFieldChecked('edit-modules-testing-bad-module-enable', 'The module bad_module is not enabled.');
+    $this->drupalGet('admin/modules/uninstall');
+    $this->assertNoText('Bad module', 'The module bad_module is not in module uninstall list.');
+
+    // The exceptions are expected. Do not interpret them as a test failure.
+    // Not using File API; a potential error must trigger a PHP warning.
+    unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
+  }
+
 }
diff --git a/core/modules/system/tests/modules/bad_module/bad_module.info.yml b/core/modules/system/tests/modules/bad_module/bad_module.info.yml
new file mode 100644
index 0000000..96e71e0
--- /dev/null
+++ b/core/modules/system/tests/modules/bad_module/bad_module.info.yml
@@ -0,0 +1,6 @@
+name: 'Bad module'
+type: module
+description: 'Don&#39;t activate me, I have a PHP syntax error.'
+package: Testing
+version: VERSION
+core: 8.x
diff --git a/core/modules/system/tests/modules/bad_module/bad_module.module b/core/modules/system/tests/modules/bad_module/bad_module.module
new file mode 100644
index 0000000..d74ebf2
--- /dev/null
+++ b/core/modules/system/tests/modules/bad_module/bad_module.module
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Implements hook_install().
+ */
+function bad_module_install() {
+  // Prevent test from collecting errors.
+  define('SIMPLETEST_COLLECT_ERRORS', FALSE);
+  // This simulates a PHP syntax error or whatever unexpected behavior that
+  // might happen during the install process of a module.
+  // @see \Drupal\system\Tests\Module\InstallTest
+  throw new Exception("PHP syntax exception !");
+}
