diff --git a/core/modules/book/book.module b/core/modules/book/book.module index bbdfab3..809964f 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -513,67 +513,66 @@ function _book_parent_select($book_link) { '#attributes' => array('class' => array('book-title-select')), '#prefix' => '
', '#suffix' => '
', ); } return $form; } /** * Builds the common elements of the book form for the node and outline forms. * * @param Drupal\node\Node $node * The node whose form is being viewed. */ function _book_add_form_elements(&$form, &$form_state, Node $node) { // If the form is being processed during the Ajax callback of our book bid // dropdown, then $form_state will hold the value that was selected. if (isset($form_state['values']['book'])) { $node->book = $form_state['values']['book']; } $form['book'] = array( '#type' => 'fieldset', '#title' => t('Book outline'), '#weight' => 10, '#collapsible' => TRUE, '#collapsed' => TRUE, '#group' => 'additional_settings', '#attributes' => array( - 'class' => array('book-form'), + 'class' => array('book-outline-form'), ), '#attached' => array( 'js' => array(drupal_get_path('module', 'book') . '/book.js'), ), '#tree' => TRUE, - '#attributes' => array('class' => array('book-outline-form')), ); foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) { $form['book'][$key] = array( '#type' => 'value', '#value' => $node->book[$key], ); } $form['book']['plid'] = _book_parent_select($node->book); // @see _book_admin_table_tree(). The weight may be larger than 15. $form['book']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#default_value' => $node->book['weight'], '#delta' => max(15, abs($node->book['weight'])), '#weight' => 5, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), ); $options = array(); $nid = isset($node->nid) ? $node->nid : 'new'; if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) { // This is the top level node in a maximum depth book and thus cannot be moved. $options[$node->nid] = $node->title; } else { foreach (book_get_books() as $book) { $options[$book['nid']] = $book['title']; } diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index dcb2a8c..f56a653 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -563,64 +563,63 @@ function file_field_widget_value($element, $input = FALSE, $form_state) { */ function file_field_widget_process($element, &$form_state, $form) { $item = $element['#value']; $item['fid'] = $element['fid']['#value']; $field = field_widget_field($element, $form_state); $instance = field_widget_instance($element, $form_state); $settings = $instance['widget']['settings']; $element['#theme'] = 'file_widget'; // Add the display field if enabled. if (!empty($field['settings']['display_field']) && $item['fid']) { $element['display'] = array( '#type' => empty($item['fid']) ? 'hidden' : 'checkbox', '#title' => t('Include file in display'), '#value' => isset($item['display']) ? $item['display'] : $field['settings']['display_default'], '#attributes' => array('class' => array('file-display')), ); } else { $element['display'] = array( '#type' => 'hidden', '#value' => '1', ); } // Add the description field if enabled. if (!empty($instance['settings']['description_field']) && $item['fid']) { $element['description'] = array( - '#type' => 'textfield', + '#type' => variable_get('file_description_type', 'textfield'), '#title' => t('Description'), '#value' => isset($item['description']) ? $item['description'] : '', - '#type' => variable_get('file_description_type', 'textfield'), '#maxlength' => variable_get('file_description_length', 128), '#description' => t('The description may be used as the label of the link to the file.'), ); } // Adjust the Ajax settings so that on upload and remove of any individual // file, the entire group of file fields is updated together. if ($field['cardinality'] != 1) { $parents = array_slice($element['#array_parents'], 0, -1); $new_path = 'file/ajax/' . implode('/', $parents) . '/' . $form['form_build_id']['#value']; $field_element = drupal_array_get_nested_value($form, $parents); $new_wrapper = $field_element['#id'] . '-ajax-wrapper'; foreach (element_children($element) as $key) { if (isset($element[$key]['#ajax'])) { $element[$key]['#ajax']['path'] = $new_path; $element[$key]['#ajax']['wrapper'] = $new_wrapper; } } unset($element['#prefix'], $element['#suffix']); } // Add another submit handler to the upload and remove buttons, to implement // functionality needed by the field widget. This submit handler, along with // the rebuild logic in file_field_widget_form() requires the entire field, // not just the individual item, to be valid. foreach (array('upload_button', 'remove_button') as $key) { $element[$key]['#submit'][] = 'file_field_widget_submit'; $element[$key]['#limit_validation_errors'] = array(array_slice($element['#parents'], 0, -1)); } diff --git a/core/modules/language/language.test b/core/modules/language/language.test index d931dc6..59d975a 100644 --- a/core/modules/language/language.test +++ b/core/modules/language/language.test @@ -475,61 +475,60 @@ class LanguageBrowserDetectionTestCase extends UnitTestBase { 'en, fr' => 'en', // A less specific language from the browser matches a more specific one // from the website, and the other way around for compatibility with // some versions of Internet Explorer. 'es' => 'es-MX', 'es-MX' => 'es-MX', 'pt' => 'pt', 'pt-PT' => 'pt', 'pt-PT;q=0.5,pt-BR;q=1,en;q=0.7' => 'en', 'pt-PT;q=1,pt-BR;q=0.5,en;q=0.7' => 'en', 'pt-PT;q=0.4,pt-BR;q=0.1,en;q=0.7' => 'en', 'pt-PT;q=0.1,pt-BR;q=0.4,en;q=0.7' => 'en', // Language code with several dashes are valid. The less specific language // from the browser matches the more specific one from the website. 'eh-oh-laa-laa' => 'eh-oh-laa-laa', 'eh-oh-laa' => 'eh-oh-laa-laa', 'eh-oh' => 'eh-oh-laa-laa', 'eh' => 'eh-oh-laa-laa', // Different qvalues. 'en-US,en;q=0.5,fr;q=0.25' => 'en-US', 'fr,en;q=0.5' => 'fr-CA', 'fr,en;q=0.5,fr-CA;q=0.25' => 'fr', // Silly wildcards are also valid. '*,fr-CA;q=0.5' => 'en', '*,en;q=0.25' => 'fr-CA', 'en,en-US;q=0.5,fr;q=0.25' => 'en', - 'en-US,en;q=0.5,fr;q=0.25' => 'en-US', // Unresolvable cases. '' => FALSE, 'de,pl' => FALSE, 'iecRswK4eh' => FALSE, $this->randomName(10) => FALSE, ); foreach ($test_cases as $accept_language => $expected_result) { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $accept_language; $result = language_from_browser($languages); $this->assertIdentical($result, $expected_result, t("Language selection '@accept-language' selects '@result', result = '@actual'", array('@accept-language' => $accept_language, '@result' => $expected_result, '@actual' => isset($result) ? $result : 'none'))); } } } /** * Test UI language negotiation * * 1. URL (PATH) > DEFAULT * UI Language base on URL prefix, browser language preference has no * influence: * admin/config * UI in site default language * zh-hans/admin/config * UI in Chinese * blah-blah/admin/config * 404 * 2. URL (PATH) > BROWSER > DEFAULT * admin/config diff --git a/core/modules/system/tests/batch.test b/core/modules/system/tests/batch.test index e39bcf5..31283ec 100644 --- a/core/modules/system/tests/batch.test +++ b/core/modules/system/tests/batch.test @@ -333,63 +333,60 @@ class BatchPercentagesUnitTestCase extends UnitTestBase { function setUp() { // Set up an array of test cases, where the expected values are the keys, // and the values are arrays with the keys 'total' and 'current', // corresponding with the function parameters of _batch_api_percentage(). $this->testCases = array( // 1/2 is 50%. '50' => array('total' => 2, 'current' => 1), // Though we should never encounter a case where the current set is set // 0, if we did, we should get 0%. '0' => array('total' => 3, 'current' => 0), // 1/3 is closer to 33% than to 34%. '33' => array('total' => 3, 'current' => 1), // 2/3 is closer to 67% than to 66%. '67' => array('total' => 3, 'current' => 2), // A full 3/3 should equal 100%. '100' => array('total' => 3, 'current' => 3), // 1/199 should round up to 1%. '1' => array('total' => 199, 'current' => 1), // 198/199 should round down to 99%. '99' => array('total' => 199, 'current' => 198), // 199/200 would have rounded up to 100%, which would give the false // impression of being finished, so we add another digit and should get // 99.5%. '99.5' => array('total' => 200, 'current' => 199), // The same logic holds for 1/200: we should get 0.5%. '0.5' => array('total' => 200, 'current' => 1), // Numbers that come out evenly, such as 50/200, should be forced to have // extra digits for consistancy. '25.0' => array('total' => 200, 'current' => 50), - // Regardless of number of digits we're using, 100% should always just be - // 100%. - '100' => array('total' => 200, 'current' => 200), // 1998/1999 should similarly round down to 99.9%. '99.9' => array('total' => 1999, 'current' => 1998), // 1999/2000 should add another digit and go to 99.95%. '99.95' => array('total' => 2000, 'current' => 1999), // 19999/20000 should add yet another digit and go to 99.995%. '99.995' => array('total' => 20000, 'current' => 19999), // The next five test cases simulate a batch with a single operation // ('total' equals 1) that takes several steps to complete. Within the // operation, we imagine that there are 501 items to process, and 100 are // completed during each step. The percentages we get back should be // rounded the usual way for the first few passes (i.e., 20%, 40%, etc.), // but for the last pass through, when 500 out of 501 items have been // processed, we do not want to round up to 100%, since that would // erroneously indicate that the processing is complete. '20' => array('total' => 1, 'current' => 100/501), '40' => array('total' => 1, 'current' => 200/501), '60' => array('total' => 1, 'current' => 300/501), '80' => array('total' => 1, 'current' => 400/501), '99.8' => array('total' => 1, 'current' => 500/501), ); require_once DRUPAL_ROOT . '/core/includes/batch.inc'; parent::setUp(); } /** * Test the _batch_api_percentage() function. */ function testBatchPercentages() { foreach ($this->testCases as $expected_result => $arguments) { // PHP sometimes casts numeric strings that are array keys to integers, diff --git a/core/modules/system/tests/form.test b/core/modules/system/tests/form.test index fe5f922..33e6175 100644 --- a/core/modules/system/tests/form.test +++ b/core/modules/system/tests/form.test @@ -46,61 +46,61 @@ class FormsTestCase extends WebTestBase { $empty_arrays = array('array()' => array()); $empty_checkbox = array(NULL); $elements['textfield']['element'] = array('#title' => $this->randomName(), '#type' => 'textfield'); $elements['textfield']['empty_values'] = $empty_strings; $elements['telephone']['element'] = array('#title' => $this->randomName(), '#type' => 'tel'); $elements['telephone']['empty_values'] = $empty_strings; $elements['url']['element'] = array('#title' => $this->randomName(), '#type' => 'url'); $elements['url']['empty_values'] = $empty_strings; $elements['search']['element'] = array('#title' => $this->randomName(), '#type' => 'search'); $elements['search']['empty_values'] = $empty_strings; $elements['password']['element'] = array('#title' => $this->randomName(), '#type' => 'password'); $elements['password']['empty_values'] = $empty_strings; $elements['password_confirm']['element'] = array('#title' => $this->randomName(), '#type' => 'password_confirm'); // Provide empty values for both password fields. foreach ($empty_strings as $key => $value) { $elements['password_confirm']['empty_values'][$key] = array('pass1' => $value, 'pass2' => $value); } $elements['textarea']['element'] = array('#title' => $this->randomName(), '#type' => 'textarea'); $elements['textarea']['empty_values'] = $empty_strings; $elements['radios']['element'] = array('#title' => $this->randomName(), '#type' => 'radios', '#options' => array('' => t('None'), $this->randomName(), $this->randomName(), $this->randomName())); $elements['radios']['empty_values'] = $empty_arrays; - $elements['checkbox']['element'] = array('#title' => $this->randomName(), '#type' => 'checkbox', '#required' => TRUE, '#title' => $this->randomName()); + $elements['checkbox']['element'] = array('#title' => $this->randomName(), '#type' => 'checkbox', '#required' => TRUE); $elements['checkbox']['empty_values'] = $empty_checkbox; $elements['checkboxes']['element'] = array('#title' => $this->randomName(), '#type' => 'checkboxes', '#options' => array($this->randomName(), $this->randomName(), $this->randomName())); $elements['checkboxes']['empty_values'] = $empty_arrays; $elements['select']['element'] = array('#title' => $this->randomName(), '#type' => 'select', '#options' => array('' => t('None'), $this->randomName(), $this->randomName(), $this->randomName())); $elements['select']['empty_values'] = $empty_strings; $elements['file']['element'] = array('#title' => $this->randomName(), '#type' => 'file'); $elements['file']['empty_values'] = $empty_strings; // Regular expression to find the expected marker on required elements. $required_marker_preg = '@\*@'; // Go through all the elements and all the empty values for them. foreach ($elements as $type => $data) { foreach ($data['empty_values'] as $key => $empty) { foreach (array(TRUE, FALSE) as $required) { $form_id = $this->randomName(); $form = array(); $form_state = form_state_defaults(); form_clear_error(); $form['op'] = array('#type' => 'submit', '#value' => t('Submit')); $element = $data['element']['#title']; $form[$element] = $data['element']; $form[$element]['#required'] = $required; $form_state['input'][$element] = $empty; $form_state['input']['form_id'] = $form_id; $form_state['method'] = 'post'; drupal_prepare_form($form_id, $form, $form_state);