3 namespace Drupal\system\Tests\Module;
6 * Attempt disabling of required modules.
10 class RequiredTest extends ModuleTestBase {
12 * Assert that core required modules cannot be disabled.
14 public function testDisableRequired() {
15 $module_info = system_get_info('module');
16 $this->drupalGet('admin/modules');
17 foreach ($module_info as $module => $info) {
18 // Check to make sure the checkbox for each required module is disabled
19 // and checked (or absent from the page if the module is also hidden).
20 if (!empty($info['required'])) {
21 $field_name = 'modules[' . $module . '][enable]';
22 if (empty($info['hidden'])) {
23 $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', ['@name' => $field_name]));
26 $this->assertNoFieldByName($field_name);