summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-01-15 14:43:16 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-01-15 14:43:16 -0500
commitdc791ec5839b52c7616bf66993122aa9a1336384 (patch)
tree547a2a35a78818030c8c4dc2e0d1999f0f4f2f1e /modules/simpletest
parenteffed1c831c997be26e12f18be0d8eb683f21a75 (diff)
downloadbrdo-dc791ec5839b52c7616bf66993122aa9a1336384.tar.gz
brdo-dc791ec5839b52c7616bf66993122aa9a1336384.tar.bz2
Drupal 7.26
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/form.test27
-rw-r--r--modules/simpletest/tests/form_test.module9
-rw-r--r--modules/simpletest/tests/upgrade/upgrade.taxonomy.test5
3 files changed, 38 insertions, 3 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 8b63be4fc..1d430b582 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -1486,6 +1486,16 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => 2)), TRUE);
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => NULL)), TRUE);
+ // Test that a programmatic form submission can successfully submit values
+ // even for fields where the #access property is FALSE.
+ $this->submitForm(array('textfield' => 'dummy value', 'textfield_no_access' => 'test value'), TRUE);
+ // Test that #access is respected for programmatic form submissions when
+ // requested to do so.
+ $submitted_values = array('textfield' => 'dummy value', 'textfield_no_access' => 'test value');
+ $expected_values = array('textfield' => 'dummy value', 'textfield_no_access' => 'default value');
+ $form_state = array('programmed_bypass_access_check' => FALSE);
+ $this->submitForm($submitted_values, TRUE, $expected_values, $form_state);
+
// Test that a programmatic form submission can correctly click a button
// that limits validation errors based on user input. Since we do not
// submit any values for "textfield" here and the textfield is required, we
@@ -1508,10 +1518,18 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
* @param $valid_input
* A boolean indicating whether or not the form submission is expected to
* be valid.
+ * @param $expected_values
+ * (Optional) An array of field values that are expected to be stored by
+ * the form submit handler. If not set, the submitted $values are assumed
+ * to also be the expected stored values.
+ * @param $form_state
+ * (Optional) A keyed array containing the state of the form, to be sent in
+ * the call to drupal_form_submit(). The $values parameter is added to
+ * $form_state['values'] by default, if it is not already set.
*/
- private function submitForm($values, $valid_input) {
+ private function submitForm($values, $valid_input, $expected_values = NULL, $form_state = array()) {
// Programmatically submit the given values.
- $form_state = array('values' => $values);
+ $form_state += array('values' => $values);
drupal_form_submit('form_test_programmatic_form', $form_state);
// Check that the form returns an error when expected, and vice versa.
@@ -1528,7 +1546,10 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
// By fetching the values from $form_state['storage'] we ensure that the
// submission handler was properly executed.
$stored_values = $form_state['storage']['programmatic_form_submit'];
- foreach ($values as $key => $value) {
+ if (!isset($expected_values)) {
+ $expected_values = $values;
+ }
+ foreach ($expected_values as $key => $value) {
$this->assertTrue(isset($stored_values[$key]) && $stored_values[$key] == $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
}
}
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index b4d2f5499..c7885d7a0 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -1548,6 +1548,15 @@ function form_test_programmatic_form($form, &$form_state) {
'#default_value' => array(1, 2),
);
+ // This is used to test that programmatic form submissions can bypass #access
+ // restrictions.
+ $form['textfield_no_access'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Textfield no access',
+ '#default_value' => 'default value',
+ '#access' => FALSE,
+ );
+
$form['field_to_validate'] = array(
'#type' => 'radios',
'#title' => 'Field to validate (in the case of limited validation)',
diff --git a/modules/simpletest/tests/upgrade/upgrade.taxonomy.test b/modules/simpletest/tests/upgrade/upgrade.taxonomy.test
index e0142f4b9..58a4d5c17 100644
--- a/modules/simpletest/tests/upgrade/upgrade.taxonomy.test
+++ b/modules/simpletest/tests/upgrade/upgrade.taxonomy.test
@@ -56,6 +56,11 @@ class UpgradePathTaxonomyTestCase extends UpgradePathTestCase {
$this->assertFalse(db_table_exists('taxonomy_vocabulary_node_type'), 'taxonomy_vocabulary_node_type has been removed.');
$this->assertFalse(db_table_exists('taxonomy_term_node'), 'taxonomy_term_node has been removed.');
+ // Check that taxonomy_index has not stored nids of unpublished nodes.
+ $nids = db_query('SELECT nid from {node} WHERE status = :status', array(':status' => NODE_NOT_PUBLISHED))->fetchCol();
+ $indexed_nids = db_query('SELECT DISTINCT nid from {taxonomy_index}')->fetchCol();
+ $this->assertFalse(array_intersect($nids, $indexed_nids), 'No unpublished nid present in taxonomy_index');
+
// Check that the node type 'page' has been associated to a taxonomy
// reference field for each vocabulary.
$voc_keys = array();