diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index 3d4b0fa..b6aa86e 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -43,6 +43,8 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable /** * Form combining two separate entities. + * + * @deprecated Use \Drupal\field_test\Form\FieldTestForm::testEntityNestedForm() */ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2) { // First entity. diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index a95d457..992e6ef 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -43,10 +43,7 @@ function field_test_menu() { $items = array(); $items['test-entity/nested/%entity_test/%entity_test'] = array( 'title' => 'Nested entity form', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_test_entity_nested_form', 2, 3), - 'access arguments' => array('administer entity_test content'), - 'type' => MENU_NORMAL_ITEM, + 'route_name' => 'field_test.entity_nested_form', ); return $items; diff --git a/core/modules/field/tests/modules/field_test/field_test.routing.yml b/core/modules/field/tests/modules/field_test/field_test.routing.yml new file mode 100644 index 0000000..355dbff --- /dev/null +++ b/core/modules/field/tests/modules/field_test/field_test.routing.yml @@ -0,0 +1,13 @@ +field_test.entity_nested_form: + path: '/test-entity/nested/{entity_1}/{entity_2}' + defaults: + _title: 'Nested entity form' + _content: '\Drupal\field_test\Form\FieldTestForm::testEntityNestedForm' + options: + parameters: + entity_1: + type: 'entity:entity_test' + entity_2: + type: 'entity:entity_test' + requirements: + _permission: 'administer entity_test content' \ No newline at end of file diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/FieldTestForm.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/FieldTestForm.php new file mode 100644 index 0000000..8c9e913 --- /dev/null +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/FieldTestForm.php @@ -0,0 +1,25 @@ + 'Form API file inclusion', - 'description' => 'Tests form API file inclusion.', - 'group' => 'Form API', - ); - } - - /** - * Tests loading an include specified in hook_menu(). - */ - function testLoadMenuInclude() { - $this->drupalPostAjaxForm('form-test/load-include-menu', array(), array('op' => t('Save')), 'system/ajax', array(), array(), 'form-test-load-include-menu'); - $this->assertText('Submit callback called.'); - } - - /** - * Tests loading a custom specified include. - */ - function testLoadCustomInclude() { - $this->drupalPostForm('form-test/load-include-custom', array(), t('Save')); - $this->assertText('Submit callback called.'); - } -} diff --git a/core/modules/system/tests/modules/form_test/form_test.file.inc b/core/modules/system/tests/modules/form_test/form_test.file.inc deleted file mode 100644 index f9197ea..0000000 --- a/core/modules/system/tests/modules/form_test/form_test.file.inc +++ /dev/null @@ -1,48 +0,0 @@ - '
', - ); - $form['button'] = array( - '#type' => 'submit', - '#value' => t('Save'), - '#submit' => array('form_test_load_include_submit'), - '#ajax' => array( - 'wrapper' => $ajax_wrapper_id, - 'method' => 'append', - 'callback' => 'form_test_load_include_menu_ajax', - ), - ); - return $form; -} - -/** - * Submit callback for the form API file inclusion test forms. - */ -function form_test_load_include_submit($form, $form_state) { - drupal_set_message('Submit callback called.'); -} - -/** - * Ajax callback for the file inclusion via menu test. - */ -function form_test_load_include_menu_ajax($form) { - // We don't need to return anything, since #ajax['method'] is 'append', which - // does not remove the original #ajax['wrapper'] element, and status messages - // are automatically added by the Ajax framework as long as there's a wrapper - // element to add them to. - return ''; -} diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 7fe368d..7a753e1 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -15,329 +15,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; /** - * Implements hook_menu(). - */ -function form_test_menu() { - $items['form-test/alter'] = array( - 'title' => 'Form altering test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_alter_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/validate'] = array( - 'title' => 'Form validation handlers test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_validate_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/validate-required'] = array( - 'title' => 'Form #required validation', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_validate_required_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/validate-required-no-title'] = array( - 'title' => 'Form #required validation without #title', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_validate_required_form_no_title'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/limit-validation-errors'] = array( - 'title' => 'Form validation with some error suppression', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_limit_validation_errors_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/pattern'] = array( - 'title' => 'Pattern validation', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_pattern_form'), - 'access callback' => TRUE, - ); - - $items['form_test/tableselect/multiple-true'] = array( - 'title' => 'Tableselect checkboxes test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_tableselect_multiple_true_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form_test/tableselect/multiple-false'] = array( - 'title' => 'Tableselect radio button test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_tableselect_multiple_false_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form_test/tableselect/colspan'] = array( - 'title' => 'Tableselect colspan test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_tableselect_colspan_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form_test/tableselect/empty-text'] = array( - 'title' => 'Tableselect empty text test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_tableselect_empty_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form_test/tableselect/advanced-select'] = array( - 'title' => 'Tableselect js_select tests', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_tableselect_js_select_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form_test/vertical-tabs'] = array( - 'title' => 'Vertical tabs tests', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_vertical_tabs_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form_test/form-storage'] = array( - 'title' => 'Form storage test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_storage_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form_test/form-state-values-clean'] = array( - 'title' => 'Form state values clearance test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_form_state_values_clean_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form_test/form-state-values-clean-advanced'] = array( - 'title' => 'Form state values clearance advanced test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_form_state_values_clean_advanced_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/checkbox'] = array( - 'title' => t('Form test'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_checkbox'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/select'] = array( - 'title' => t('Select'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_select'), - 'access callback' => TRUE, - ); - $items['form-test/empty-select'] = array( - 'title' => 'Empty Select Element', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_empty_select'), - 'access callback' => TRUE, - ); - $items['form-test/language_select'] = array( - 'title' => t('Language Select'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_language_select'), - 'access callback' => TRUE, - ); - $items['form-test/placeholder-text'] = array( - 'title' => 'Placeholder', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_placeholder_test'), - 'access callback' => TRUE, - ); - $items['form-test/number'] = array( - 'title' => 'Number', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_number'), - 'access callback' => TRUE, - ); - $items['form-test/number/range'] = array( - 'title' => 'Range', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_number', 'range'), - 'access callback' => TRUE, - ); - $items['form-test/range']= array( - 'title' => 'Range', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_range'), - 'access callback' => TRUE, - ); - $items['form-test/range/invalid'] = array( - 'title' => 'Invalid range', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_range_invalid'), - 'access callback' => TRUE, - ); - $items['form-test/color'] = array( - 'title' => 'Color', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_color'), - 'access callback' => TRUE, - ); - $items['form-test/checkboxes-radios'] = array( - 'title' => t('Checkboxes, Radios'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_checkboxes_radios'), - 'access callback' => TRUE, - ); - $items['form-test/email'] = array( - 'title' => 'E-Mail fields', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_email'), - 'access callback' => TRUE, - ); - $items['form-test/url'] = array( - 'title' => t('URL'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_url'), - 'access callback' => TRUE, - ); - - $items['form-test/disabled-elements'] = array( - 'title' => t('Form test'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_disabled_elements'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/input-forgery'] = array( - 'title' => t('Form test'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('_form_test_input_forgery'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/form-rebuild-preserve-values'] = array( - 'title' => 'Form values preservation during rebuild test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_form_rebuild_preserve_values_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/redirect'] = array( - 'title' => 'Redirect test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_redirect'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form_test/form-labels'] = array( - 'title' => 'Form label test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_label_test_form'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/state-persist'] = array( - 'title' => 'Form state persistence without storage', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_state_persist'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/clicked-button'] = array( - 'title' => 'Clicked button test', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_clicked_button'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/load-include-menu'] = array( - 'title' => 'FAPI test loading includes', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_load_include_menu'), - 'access callback' => TRUE, - 'file' => 'form_test.file.inc', - 'type' => MENU_CALLBACK, - ); - - $items['form-test/load-include-custom'] = array( - 'title' => 'FAPI test loading includes', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_load_include_custom'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['form-test/checkboxes-zero'] = array( - 'title' => 'FAPI test involving checkboxes and zero', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_checkboxes_zero'), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['form-test/required-attribute'] = array( - 'title' => 'Required', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_required_attribute'), - 'access callback' => TRUE, - ); - $items['form-test/button-class'] = array( - 'title' => 'Button class testing', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_button_class'), - 'access callback' => TRUE, - ); - - $items['form-test/group-details'] = array( - 'title' => 'Group details testing', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_group_details'), - 'access callback' => TRUE, - ); - $items['form-test/group-container'] = array( - 'title' => 'Group container testing', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_group_container'), - 'access callback' => TRUE, - ); - $items['form-test/group-fieldset'] = array( - 'title' => 'Group fieldset testing', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_group_fieldset'), - 'access callback' => TRUE, - ); - $items['form-test/group-vertical-tabs'] = array( - 'title' => 'Group vertical tabs testing', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_group_vertical_tabs'), - 'access callback' => TRUE, - ); - - $items['form-test/form_state-database'] = array( - 'title' => t('Form state with a database connection'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('form_test_form_state_database'), - 'access callback' => TRUE, - ); - - return $items; -} - - -/** * Implements hook_permission(). */ function form_test_permission() { @@ -364,6 +41,8 @@ function _form_test_submit_values_json($form, &$form_state) { /** * Form builder for testing hook_form_alter() and hook_form_FORM_ID_alter(). + * + * @deprecated Use \Drupal\form_test\alterForm() */ function form_test_alter_form($form, &$form_state) { // Elements can be added as needed for future testing needs, but for now, @@ -413,6 +92,8 @@ function system_form_form_test_alter_form_alter(&$form, &$form_state) { * structure and the alterations should be contained in the rebuilt form. * - #validate handlers should be able to alter the $form and the alterations * should be contained in the rebuilt form. + * + * @deprecated Use \Drupal\form_test\validateForm() */ function form_test_validate_form($form, &$form_state) { $object = new Callbacks(); @@ -454,6 +135,8 @@ function form_test_validate_form_validate(&$form, &$form_state) { /** * Form constructor to test the #required property. + * + * @deprecated Use \Drupal\form_test\validateRequiredForm() */ function form_test_validate_required_form($form, &$form_state) { $options = drupal_map_assoc(array('foo', 'bar')); @@ -522,6 +205,8 @@ function form_test_validate_required_form_submit($form, &$form_state) { /** * Form constructor to test the #required property without #title. + * + * @deprecated Use \Drupal\form_test\validateRequiredFormNoTitle() */ function form_test_validate_required_form_no_title($form, &$form_state) { $form['textfield'] = array( @@ -542,6 +227,8 @@ function form_test_validate_required_form_no_title_submit($form, &$form_state) { /** * Builds a simple form with a button triggering partial validation. + * + * @deprecated Use \Drupal\form_test\validateFormWithErrorSuppression() */ function form_test_limit_validation_errors_form($form, &$form_state) { $form['title'] = array( @@ -625,6 +312,8 @@ function form_test_limit_validation_errors_form_partial_submit($form, $form_stat /** * Builds a simple form using the FAPI #pattern proterty. + * + * @deprecated Use \Drupal\form_test\validatePattern() */ function form_test_pattern_form($form, &$form_state) { $form['textfield'] = array( @@ -730,6 +419,8 @@ function _form_test_tableselect_form_builder($form, $form_state, $element_proper /** * Test the tableselect #multiple = TRUE functionality. + * + * @deprecated Use \Drupal\form_test\testTableSelectCheckboxes() */ function _form_test_tableselect_multiple_true_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => TRUE)); @@ -747,6 +438,8 @@ function _form_test_tableselect_multiple_true_form_submit($form, &$form_state) { /** * Test the tableselect #multiple = FALSE functionality. + * + * @deprecated Use \Drupal\form_test\testTableSelectRadios() */ function _form_test_tableselect_multiple_false_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => FALSE)); @@ -754,6 +447,8 @@ function _form_test_tableselect_multiple_false_form($form, $form_state) { /** * Test the tableselect #colspan functionality. + * + * @deprecated Use \Drupal\form_test\testTableSelectColspan() */ function _form_test_tableselect_colspan_form($form, $form_state) { list($header, $options) = _form_test_tableselect_get_data(); @@ -784,6 +479,8 @@ function _form_test_tableselect_multiple_false_form_submit($form, &$form_state) /** * Test functionality of the tableselect #empty property. + * + * @deprecated Use \Drupal\form_test\testTableSelectEmptyText() */ function _form_test_tableselect_empty_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#options' => array())); @@ -791,6 +488,8 @@ function _form_test_tableselect_empty_form($form, $form_state) { /** * Test functionality of the tableselect #js_select property. + * + * @deprecated Use \Drupal\form_test\testTableSelectJS() */ function _form_test_tableselect_js_select_form($form, $form_state, $action) { switch ($action) { @@ -816,6 +515,8 @@ function _form_test_tableselect_js_select_form($form, $form_state, $action) { /** * Tests functionality of vertical tabs. + * + * @deprecated Use \Drupal\form_test\testVerticalTabs() */ function _form_test_vertical_tabs_form($form, &$form_state) { $form['vertical_tabs'] = array( @@ -853,6 +554,8 @@ function _form_test_vertical_tabs_form($form, &$form_state) { * it would be the case, if the form would contain some #ajax callbacks. * * @see form_test_storage_form_submit() + * + * @deprecated Use \Drupal\form_test\testStorage() */ function form_test_storage_form($form, &$form_state) { if ($form_state['rebuild']) { @@ -949,6 +652,8 @@ function form_test_storage_form_submit($form, &$form_state) { /** * A form for testing form labels and required marks. + * + * @deprecated Use \Drupal\form_test\testLabel() */ function form_label_test_form() { $form['form_checkboxes_test'] = array( @@ -1060,6 +765,8 @@ function form_test_wrapper_callback_wrapper($form, &$form_state) { /** * Form builder for form wrapper callback test. + * + * @deprecated Use \Drupal\form_test\testWrapperCallback() */ function form_test_wrapper_callback_form($form, &$form_state) { $form['builder'] = array('#markup' => 'Form builder element output.'); @@ -1068,6 +775,8 @@ function form_test_wrapper_callback_form($form, &$form_state) { /** * Form builder for form_state_values_clean() test. + * + * @deprecated Use \Drupal\form_test\testFormStateClean() */ function form_test_form_state_values_clean_form($form, &$form_state) { // Build an example form containing multiple submit and button elements; not @@ -1095,6 +804,8 @@ function form_test_form_state_values_clean_form_submit($form, &$form_state) { /** * Form constructor for the form_state_values_clean() test. + * + * @deprecated Use \Drupal\form_test\testFormStateCleanAdvanced() */ function form_test_form_state_values_clean_advanced_form($form, &$form_state) { // Build an example form containing a managed file and a submit form element. @@ -1122,6 +833,8 @@ function form_test_form_state_values_clean_advanced_form_submit($form, &$form_st /** * Build a form to test a checkbox. + * + * @deprecated Use \Drupal\form_test\testCheckbox() */ function _form_test_checkbox($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1191,6 +904,8 @@ function _form_test_checkbox($form, &$form_state) { /** * Builds a form to test #type 'select' validation. + * + * @deprecated Use \Drupal\form_test\testSelect() */ function form_test_select($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1294,6 +1009,8 @@ function form_test_select($form, &$form_state) { /** * Builds a form to test select elements when #options is not an array. + * + * @deprecated Use \Drupal\form_test\testEmptySelect() */ function form_test_empty_select($form, &$form_state) { $form['empty_select'] = array( @@ -1307,6 +1024,8 @@ function form_test_empty_select($form, &$form_state) { /** * Builds a form to test the language select form element. + * + * @deprecated Use \Drupal\form_test\testLanguageSelect() */ function form_test_language_select() { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1351,6 +1070,10 @@ function form_test_language_select() { * * @param $element * The element type to test. Can be 'number' or 'range'. Defaults to 'number'. + * + * @deprecated Use \Drupal\form_test\testNumber() + * + * @deprecated Use \Drupal\form_test\testNumberRange() */ function form_test_number($form, &$form_state, $element = 'number') { $base = array( @@ -1469,6 +1192,8 @@ function form_test_number($form, &$form_state, $element = 'number') { * * @see form_test_range_submit() * @ingroup forms + * + * @deprecated Use \Drupal\form_test\testRange() */ function form_test_range($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1516,6 +1241,8 @@ function form_test_range($form, &$form_state) { * Form constructor for testing invalid #type 'range' elements. * * @ingroup forms + * + * @deprecated Use \Drupal\form_test\testRangeInvalid() */ function form_test_range_invalid($form, &$form_state) { $form['minmax'] = array( @@ -1537,6 +1264,8 @@ function form_test_range_invalid($form, &$form_state) { * * @see form_test_color_submit() * @ingroup forms + * + * @deprecated Use \Drupal\form_test\testColor() */ function form_test_color($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1554,6 +1283,8 @@ function form_test_color($form, &$form_state) { /** * Builds a form to test the placeholder attribute. + * + * @deprecated Use \Drupal\form_test\testPlaceholder() */ function form_test_placeholder_test($form, &$form_state) { foreach (array('textfield', 'textarea', 'url', 'password', 'search', 'tel', 'email', 'number') as $type) { @@ -1569,6 +1300,8 @@ function form_test_placeholder_test($form, &$form_state) { /** * Form constructor to test expansion of #type checkboxes and radios. + * + * @deprecated Use \Drupal\form_test\testCheckboxesRadios() */ function form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1631,6 +1364,8 @@ function form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) { * * @see form_test_email_submit() * @ingroup forms + * + * @deprecated Use \Drupal\form_test\testEmail() */ function form_test_email($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1657,6 +1392,8 @@ function form_test_email($form, &$form_state) { * * @see form_test_url_submit() * @ingroup forms + * + * @deprecated Use \Drupal\form_test\testUrl() */ function form_test_url($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1680,6 +1417,8 @@ function form_test_url($form, &$form_state) { /** * Build a form to test disabled elements. + * + * @deprecated Use \Drupal\form_test\testDisabledElements() */ function _form_test_disabled_elements($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1879,6 +1618,8 @@ function _form_test_disabled_elements($form, &$form_state) { /** * Build a form to test input forgery of enabled elements. + * + * @deprecated Use \Drupal\form_test\testInputForgery() */ function _form_test_input_forgery($form, &$form_state) { $form['#submit'] = array('_form_test_submit_values_json'); @@ -1902,6 +1643,8 @@ function _form_test_input_forgery($form, &$form_state) { /** * Form builder for testing preservation of values during a rebuild. + * + * @deprecated Use \Drupal\form_test\testRebuildPreservation() */ function form_test_form_rebuild_preserve_values_form($form, &$form_state) { // Start the form with two checkboxes, to test different defaults, and a @@ -1980,6 +1723,8 @@ function form_test_form_rebuild_preserve_values_form_submit($form, &$form_state) /** * Form constructor for testing form state persistence. + * + * @deprecated Use \Drupal\form_test\testStatePersistence() */ function form_test_state_persist($form, &$form_state) { $form['title'] = array( @@ -2101,6 +1846,8 @@ function form_test_programmatic_form_submit($form, &$form_state) { /** * Form builder to test button click detection. + * + * @deprecated Use \Drupal\form_test\testClickedButton() */ function form_test_clicked_button($form, &$form_state) { // A single text field. In IE, when a form has only one non-button input field @@ -2179,6 +1926,8 @@ function form_test_clicked_button_submit($form, &$form_state) { /** * Form builder to detect form redirect. + * + * @deprecated Use \Drupal\form_test\testRedirect() */ function form_test_redirect($form, &$form_state) { $form['redirection'] = array( @@ -2240,24 +1989,6 @@ function form_test_user_register_form_rebuild($form, &$form_state) { $form_state['rebuild'] = TRUE; } -/** - * Menu callback for testing custom form includes. - */ -function form_test_load_include_custom($form, &$form_state) { - $form['button'] = array( - '#type' => 'submit', - '#value' => t('Save'), - '#submit' => array('form_test_load_include_submit'), - ); - // Specify the include file and enable form caching. That way the form is - // cached when it is submitted, but needs to find the specified submit handler - // in the include. - // Filename is a bit weird here: modules/system/tests/form_test.file.inc - form_load_include($form_state, 'inc', 'form_test', 'form_test.file'); - $form_state['cache'] = TRUE; - return $form; -} - function form_test_checkbox_type_juggling($form, $form_state, $default_value, $return_value) { $form['checkbox'] = array( '#title' => t('Checkbox'), @@ -2268,6 +1999,11 @@ function form_test_checkbox_type_juggling($form, $form_state, $default_value, $r return $form; } +/** + * Tests checkboxes zero. + * + * @deprecated Use \Drupal\form_test\testCheckboxesZero() + */ function form_test_checkboxes_zero($form, &$form_state, $json = TRUE) { $form['checkbox_off'] = array( '#title' => t('Checkbox off'), @@ -2305,6 +2041,8 @@ function _form_test_checkboxes_zero_no_redirect($form, &$form_state) { /** * Builds a form to test the required attribute. + * + * @deprecated Use \Drupal\form_test\testRequired() */ function form_test_required_attribute($form, &$form_state) { foreach (array('textfield', 'textarea', 'password') as $type) { @@ -2348,6 +2086,8 @@ function form_test_html_id($form, &$form_state) { /** * Builds a simple form to test form button classes. + * + * @deprecated Use \Drupal\form_test\testButtonClass() */ function form_test_button_class($form, &$form_state) { $form['button'] = array( @@ -2365,6 +2105,8 @@ function form_test_button_class($form, &$form_state) { /** * Builds a simple form to test the #group property on #type 'details'. + * + * @deprecated Use \Drupal\form_test\testGroupDetails() */ function form_test_group_details() { $form['details'] = array( @@ -2385,6 +2127,8 @@ function form_test_group_details() { /** * Builds a simple form to test the #group property on #type 'container'. + * + * @deprecated Use \Drupal\form_test\testGroupContainer() */ function form_test_group_container() { $form['container'] = array( @@ -2404,6 +2148,8 @@ function form_test_group_container() { /** * Builds a simple form to test the #group property on #type 'fieldset'. + * + * @deprecated Use \Drupal\form_test\testGroupFieldset() */ function form_test_group_fieldset() { $form['fieldset'] = array( @@ -2424,6 +2170,8 @@ function form_test_group_fieldset() { /** * Builds a simple form to test the #group property on #type 'vertical_tabs'. + * + * @deprecated Use \Drupal\form_test\testGroupVerticalTabs() */ function form_test_group_vertical_tabs() { $form['vertical_tabs'] = array( @@ -2452,6 +2200,8 @@ function form_test_group_vertical_tabs() { /** * Builds a form which gets the database connection stored in the form state. + * + * @deprecated Use \Drupal\form_test\testFormStateDatabase() */ function form_test_form_state_database($form, &$form_state) { $form['text'] = array( diff --git a/core/modules/system/tests/modules/form_test/form_test.routing.yml b/core/modules/system/tests/modules/form_test/form_test.routing.yml index e0997a5..0067dc5 100644 --- a/core/modules/system/tests/modules/form_test/form_test.routing.yml +++ b/core/modules/system/tests/modules/form_test/form_test.routing.yml @@ -84,3 +84,348 @@ form_test.double_form: _content: '\Drupal\form_test\Controller\FormTestController::doubleForm' requirements: _access: 'TRUE' + +form_test.alter_form: + path: '/form-test/alter' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::alterForm' + _title: 'Form altering test' + requirements: + _access: 'TRUE' + +form_test.validate_form: + path: '/form-test/validate' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::validateForm' + _title: 'Form validation handlers test' + requirements: + _access: 'TRUE' + +form_test.validate_required: + path: '/form-test/validate-required' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::validateRequiredForm' + _title: 'Form #required validation' + requirements: + _access: 'TRUE' + +form_test.validate_required_no_title: + path: '/form-test/validate-required-no-title' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::validateRequiredFormNoTitle' + _title: 'Form #required validation without #title' + requirements: + _access: 'TRUE' + +form_test.validate_with_error_suppresion: + path: '/form-test/limit-validation-errors' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::validateFormWithErrorSuppression' + _title: 'Form validation with some error suppression' + requirements: + _access: 'TRUE' + +form_test.pattern: + path: '/form-test/pattern' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::validatePattern' + _title: 'Pattern validation' + requirements: + _access: 'TRUE' + +form_test.tableselect_checkboxes: + path: '/form_test/tableselect/multiple-true' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testTableSelectCheckboxes' + _title: 'Tableselect checkboxes test' + requirements: + _access: 'TRUE' + +form_test.tableselect_radios: + path: '/form_test/tableselect/multiple-false' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testTableSelectRadios' + _title: 'Tableselect radio button test' + requirements: + _access: 'TRUE' + +form_test.tableselect_colspan: + path: '/form_test/tableselect/colspan' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testTableSelectColspan' + _title: 'Tableselect colspan test' + requirements: + _access: 'TRUE' + +form_test.tableselect_empty_text: + path: '/form_test/tableselect/empty-text' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testTableSelectEmptyText' + _title: 'Tableselect empty text test' + requirements: + _access: 'TRUE' + +form_test.tableselect_js: + path: '/form_test/tableselect/advanced-select/{test_action}' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testTableSelectJS' + _title: 'Tableselect js_select tests' + requirements: + _access: 'TRUE' + +form_test.vertical_tabs: + path: '/form_test/vertical-tabs' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testVerticalTabs' + _title: 'Vertical tabs tests' + requirements: + _access: 'TRUE' + +form_test.storage: + path: '/form_test/form-storage' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testStorage' + _title: 'Form storage test' + requirements: + _access: 'TRUE' + +form_test.state_clean: + path: '/form_test/form-state-values-clean' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testFormStateClean' + _title: 'Form state values clearance test' + requirements: + _access: 'TRUE' + +form_test.state_clean_advanced: + path: '/form_test/form-state-values-clean-advanced' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testFormStateCleanAdvanced' + _title: 'Form state values clearance advanced test' + requirements: + _access: 'TRUE' + +form_test.checkbox: + path: '/form-test/checkbox' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testCheckbox' + _title: 'Form test' + requirements: + _access: 'TRUE' + +form_test.select: + path: '/form-test/select' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testSelect' + _title: 'Select' + requirements: + _access: 'TRUE' + +form_test.empty_select: + path: '/form-test/empty-select' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testEmptySelect' + _title: 'Empty Select Element' + requirements: + _access: 'TRUE' + +form_test.language_select: + path: '/form-test/language_select' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testLanguageSelect' + _title: 'Language Select' + requirements: + _access: 'TRUE' + +form_test.placeholder: + path: '/form-test/placeholder-text' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testPlaceholder' + _title: 'Placeholder' + requirements: + _access: 'TRUE' + +form_test.number: + path: '/form-test/number' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testNumber' + _title: 'Number' + requirements: + _access: 'TRUE' + +form_test.number_range: + path: '/form-test/number/range' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testNumberRange' + _title: 'Range' + requirements: + _access: 'TRUE' + +form_test.range: + path: '/form-test/range' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testRange' + _title: 'Range' + requirements: + _access: 'TRUE' + +form_test.range_invalid: + path: '/form-test/range/invalid' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testRangeInvalid' + _title: 'Invalid range' + requirements: + _access: 'TRUE' + +form_test.color: + path: '/form-test/color' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testColor' + _title: 'Color' + requirements: + _access: 'TRUE' + +form_test.checkboxes_radios: + path: '/form-test/checkboxes-radios' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testCheckboxesRadios' + _title: 'Checkboxes, Radios' + requirements: + _access: 'TRUE' + +form_test.email: + path: '/form-test/email' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testEmail' + _title: 'E-Mail fields' + requirements: + _access: 'TRUE' + +form_test.url: + path: '/form-test/url' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testUrl' + _title: 'URL' + requirements: + _access: 'TRUE' + +form_test.disabled_elements: + path: '/form-test/disabled-elements' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testDisabledElements' + _title: 'Form test' + requirements: + _access: 'TRUE' + +form_test.input_forgery: + path: '/form-test/input-forgery' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testInputForgery' + _title: 'Form test' + requirements: + _access: 'TRUE' + +form_test.rebuild_preservation: + path: '/form-test/form-rebuild-preserve-values' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testRebuildPreservation' + _title: 'Form values preservation during rebuild test' + requirements: + _access: 'TRUE' + +form_test.redirect: + path: '/form-test/redirect' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testRedirect' + _title: 'Redirect test' + requirements: + _access: 'TRUE' + +form_test.label: + path: '/form_test/form-labels' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testLabel' + _title: 'Form label test' + requirements: + _access: 'TRUE' + +form_test.state_persistence: + path: '/form-test/state-persist' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testStatePersistence' + _title: 'Form state persistence without storage' + requirements: + _access: 'TRUE' + +form_test.clicked_button: + path: '/form-test/clicked-button' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testClickedButton' + _title: 'Clicked button test' + requirements: + _access: 'TRUE' + +form_test.checkboxes_zero: + path: '/form-test/checkboxes-zero/{json}' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testCheckboxesZero' + _title: 'FAPI test involving checkboxes and zero' + json: TRUE + requirements: + _access: 'TRUE' + +form_test.required: + path: '/form-test/required-attribute' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testRequired' + _title: 'Required' + requirements: + _access: 'TRUE' + +form_test.button_class: + path: '/form-test/button-class' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testButtonClass' + _title: 'Button class testing' + requirements: + _access: 'TRUE' + +form_test.group_details: + path: '/form-test/group-details' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testGroupDetails' + _title: 'Group details testing' + requirements: + _access: 'TRUE' + +form_test.group_container: + path: '/form-test/group-container' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testGroupContainer' + _title: 'Group container testing' + requirements: + _access: 'TRUE' + +form_test.group_fieldset: + path: '/form-test/group-fieldset' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testGroupFieldset' + _title: 'Group fieldset testing' + requirements: + _access: 'TRUE' + +form_test.group_vertical_tabs: + path: '/form-test/group-vertical-tabs' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testGroupVerticalTabs' + _title: 'Group vertical tabs testing' + requirements: + _access: 'TRUE' + +form_test.form_state_database: + path: 'form-test/form_state-database' + defaults: + _content: '\Drupal\form_test\Form\FormTestForm::testFormStateDatabase' + _title: 'Form state with a database connection' + requirements: + _access: 'TRUE' diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php new file mode 100644 index 0000000..ba1c7fb --- /dev/null +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php @@ -0,0 +1,411 @@ +