diff --git a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php index 07c3149..a9c6512 100644 --- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php @@ -17,7 +17,6 @@ * @code * $form['pass'] = array( * '#type' => 'password_confirm', - * '#title' => $this->t('Password'), * '#size' => 25, * ); * @endcode @@ -68,6 +67,9 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * Expand a password_confirm field into two text boxes. */ public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) { + // Remove the type from the wrapper of the expanded elements. + unset($element['#type']); + $element['pass1'] = [ '#type' => 'password', '#title' => t('Password'), diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 4899d0b..d695968 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -111,8 +111,6 @@ public function form(array $form, FormStateInterface $form_state) { if (!$register) { $form['account']['pass'] = [ '#type' => 'password_confirm', - '#title' => $this->t('Password'), - '#title_display' => 'invisible', '#size' => 25, '#description' => $this->t('To change the current user password, enter the new password in both fields.'), ]; @@ -155,8 +153,6 @@ public function form(array $form, FormStateInterface $form_state) { elseif (!$config->get('verify_mail') || $admin) { $form['account']['pass'] = [ '#type' => 'password_confirm', - '#title' => $this->t('Password'), - '#title_display' => 'invisible', '#size' => 25, '#description' => $this->t('Provide a password for the new account in both fields.'), '#required' => TRUE, diff --git a/core/tests/Drupal/KernelTests/Core/Form/FormElementTitleTest.php b/core/tests/Drupal/KernelTests/Core/Form/FormElementTitleTest.php index 4ffa6a4..6edaa22 100644 --- a/core/tests/Drupal/KernelTests/Core/Form/FormElementTitleTest.php +++ b/core/tests/Drupal/KernelTests/Core/Form/FormElementTitleTest.php @@ -42,7 +42,7 @@ class FormElementTitleTest extends KernelTestBase implements ServiceModifierInte /** * {@inheritdoc} */ - protected static $modules = ['system', 'user', 'ckeditor']; + protected static $modules = ['system', 'user']; /** * The render element types to ignore. @@ -76,6 +76,13 @@ protected function setUp() { $user = User::create(['name' => 'Clu']); $user->save(); $this->container->get('current_user')->setAccount($user); + + // Install all non-test modules. + $all_modules = array_filter(system_rebuild_module_data(), function ($module) { + return $module->info['package'] !== 'Testing'; + }); + $this->container->get('module_installer')->install(array_keys($all_modules)); + } /** @@ -91,11 +98,12 @@ public function alter(ContainerBuilder $container) { * Performs accessibility tests on all forms provided by modules. */ public function testFormAccessibility() { - // Find all forms in all modules, installing all modules that provide forms. + // Find all forms. $forms = $this->findForms(); // Create an entity of each type needed by forms. $entities = $this->createEntities(); + // Prepare the additional parameters for special form classes. $this->prepareForms($entities); @@ -108,26 +116,40 @@ public function testFormAccessibility() { } } + // Check all non-entity forms. $this->checkForms($forms, $entities, NULL); } /** + * Gets the directories for all namespaces that may contain forms. + * + * @return string[] + * An associative array of directories, keyed by their namespace. + */ + protected function getDirectories() { + // This contains the namespaces of all enabled modules, as well as some + // arbitrary portion of \Drupal\Core. + $directories = $this->container->get('container.namespaces'); + + // Add in the remaining namespaces for \Drupal\Core. + foreach (new \FilesystemIterator($this->root . '/core/lib/Drupal/Core', \FilesystemIterator::SKIP_DOTS) as $component) { + if ($component->isDir()) { + $directories['Drupal\\Core\\' . $component->getFilename()] = 'core/lib/Drupal/Core/' . $component->getFilename(); + } + } + + return $directories; + } + + /** * Finds all defined forms. * - * Also installs every module that provides forms. - * * @return string[] * An array of fully qualified class names of forms. */ protected function findForms() { - // Scan all modules for forms. $forms = []; - $discovery = new ExtensionDiscovery($this->root); - $modules = $discovery->scan('module', FALSE); - $modules_to_install = []; - foreach ($modules as $module) { - $module_name = $module->getName(); - $directory = $module->getPath() . '/src'; + foreach ($this->getDirectories() as $namespace => $directory) { if (is_dir($directory)) { $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS) @@ -136,39 +158,31 @@ protected function findForms() { if ($file_info->getExtension() == 'php') { $sub_path = $iterator->getSubIterator()->getSubPath(); $sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : ''; - $class = "Drupal\\$module_name\\$sub_path" . $file_info->getBasename('.php'); + $class = $namespace . '\\' . $sub_path . $file_info->getBasename('.php'); if (is_subclass_of($class, FormInterface::class)) { + // Entity forms are handled directly. + if (is_subclass_of($class, EntityFormInterface::class)) { + continue; + } + + // Entity list builders that provide forms are handled directly. + if (is_subclass_of($class, EntityListBuilderInterface::class)) { + continue; + } + + // Don't attempt to instantiate abstract forms. + if ((new \ReflectionClass($class))->isAbstract()) { + continue; + } + $forms[] = $class; - $modules_to_install[$module_name] = $module_name; } } } } } - // Install every module that provides a form. - $this->container->get('module_installer')->install($modules_to_install); - - $forms = array_filter($forms, function ($class) { - // Don't attempt to instantiate abstract forms. - if ((new \ReflectionClass($class))->isAbstract()) { - return FALSE; - } - - // Entity forms will be handled directly. - if (is_subclass_of($class, EntityFormInterface::class)) { - return FALSE; - } - - // Entity list builders that provide forms will be handled directly. - if (is_subclass_of($class, EntityListBuilderInterface::class)) { - return FALSE; - } - - return TRUE; - }); - return $forms; } @@ -391,6 +405,9 @@ protected function prepareForms(array $entities) { define('DRUPAL_TEST_IN_CHILD_SITE', FALSE); } + // Needed for \Drupal\Core\Installer\Form\SelectLanguageForm. + require_once $this->root . '/core/includes/install.core.inc'; + $tempstore = $this->container->get('user.private_tempstore'); // Needed for \Drupal\user\Form\UserMultipleCancelConfirm. @@ -635,6 +652,10 @@ protected function getArguments($object, $method, array $entities) { $objects['entity'] = $entities['node']; break; + case 'Drupal\Core\Installer\Form\SelectProfileForm': + $scalars['install_state'] = ['profiles' => []]; + break; + } return (new ArgumentsResolver($scalars, $objects, []))->getArguments([$object, $method]);