Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.19
diff -u -p -r1.19 node.test
--- modules/node/node.test 31 Mar 2009 01:49:52 -0000 1.19
+++ modules/node/node.test 6 Apr 2009 15:29:07 -0000
@@ -350,7 +350,7 @@ class PageEditTestCase extends DrupalWeb
// Check that the title and body fields are displayed with the correct values.
$this->assertLink(t('Edit'), 0, t('Edit tab found.'));
$this->assertFieldByName('title', $edit['title'], t('Title field displayed.'));
- $this->assertFieldByName('body', '' . $edit['body'], t('Body field displayed.'));
+ $this->assertFieldByName('body', $edit['body'], t('Body field displayed.'));
// Edit the content of the node.
$edit = array();
@@ -398,7 +398,7 @@ class PagePreviewTestCase extends Drupal
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('title', $edit['title'], t('Title field displayed.'));
- $this->assertFieldByName('body', '' . $edit['body'], t('Body field displayed.'));
+ $this->assertFieldByName('body', $edit['body'], t('Body field displayed.'));
}
}
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.92
diff -u -p -r1.92 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php 30 Mar 2009 05:35:35 -0000 1.92
+++ modules/simpletest/drupal_web_test_case.php 6 Apr 2009 15:29:08 -0000
@@ -1114,15 +1114,28 @@ class DrupalWebTestCase {
* @param $submit
* Value of the submit button.
* @param $options
- * Options to be forwarded to url().
- * @param $headers
- * An array containing additional HTTP request headers, each formatted as
- * "name: value".
- */
- protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array()) {
+ * Array with additional options. The following keys can be used:
+ *
+ * url_options: Array with options for url().
+ * headers: Array with HTTP headers, each formatted as "name: value".
+ * additional_post: Array with additional POST data in the format
+ * array('key' => 'value').
+ *
+ * additional_post can be used to send values for disabled form fields.
+ * Example:
+ * $options = array('additional_post' => array('disabled_field' => value));
+ */
+ protected function drupalPost($path, $edit, $submit, array $options = array()) {
+
+ $options += array(
+ 'url_options' => array(),
+ 'headers' => array(),
+ 'additional_post' => array(),
+ );
+
$submit_matches = FALSE;
if (isset($path)) {
- $html = $this->drupalGet($path, $options);
+ $html = $this->drupalGet($path, $options['url_options']);
}
if ($this->parse()) {
$edit_save = $edit;
@@ -1139,6 +1152,7 @@ class DrupalWebTestCase {
// We post only if we managed to handle every field in edit and the
// submit button matches.
if (!$edit && $submit_matches) {
+ $post += $options['additional_post'];
if ($upload) {
// TODO: cURL handles file uploads for us, but the implementation
// is broken. This is a less than elegant workaround. Alternatives
@@ -1159,7 +1173,7 @@ class DrupalWebTestCase {
}
$post = implode('&', $post);
}
- $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
+ $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $options['headers']));
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
@@ -1244,6 +1258,18 @@ class DrupalWebTestCase {
foreach ($elements as $element) {
// SimpleXML objects need string casting all the time.
$name = (string) $element['name'];
+
+ // Generate a failue when disabled elements are set, as those cannot be 'successful' (ie. be part
+ // of form submissions), according to:
+ // http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.12
+ if (!empty($element['disabled'])) {
+ if (isset($edit[$name])) {
+ $this->fail(t('Field @name is not disabled, sending of disabled fields is not allowed.', array('@name' => $name)));
+ }
+ unset($edit[$name]);
+ continue;
+ }
+
// This can either be the type of or the name of the tag itself
// for