Commit d47cfa0e authored by catch's avatar catch

Issue #2949834 by alexpott: RequiredTest is not testing what it thinks it is testing

parent f12edd4d
<?php
namespace Drupal\Tests\system\Functional\Module;
/**
* Attempt disabling of required modules.
*
* @group Module
*/
class RequiredTest extends ModuleTestBase {
/**
* Assert that core required modules cannot be disabled.
*/
public function testDisableRequired() {
$module_info = system_get_info('module');
$this->drupalGet('admin/modules');
foreach ($module_info as $module => $info) {
// Check to make sure the checkbox for each required module is disabled
// and checked (or absent from the page if the module is also hidden).
if (!empty($info['required'])) {
$field_name = 'modules[' . $module . '][enable]';
if (empty($info['hidden'])) {
$this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', ['@name' => $field_name]));
}
else {
$this->assertNoFieldByName($field_name);
}
}
}
}
}
......@@ -57,6 +57,17 @@ public function testUninstallPage() {
$this->drupalGet('admin/modules/uninstall');
$this->assertTitle(t('Uninstall') . ' | Drupal');
foreach (\Drupal::service('extension.list.module')->getAllInstalledInfo() as $module => $info) {
$field_name = "uninstall[$module]";
if (!empty($info['required'])) {
// A required module should not be listed on the uninstall page.
$this->assertSession()->fieldNotExists($field_name);
}
else {
$this->assertSession()->fieldExists($field_name);
}
}
// Be sure labels are rendered properly.
// @see regression https://www.drupal.org/node/2512106
$this->assertRaw('<label for="edit-uninstall-node" class="module-name table-filter-text-source">Node</label>');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment