#335035: simpletest should skip disabled field on POST submissions. From: Damien Tournoud According to [1], disabled controls cannot be successful (ie. 'valid for submission'). [1] http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.12 --- node/node.test | 4 ++-- simpletest/drupal_web_test_case.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git modules/node/node.test modules/node/node.test index a4c7171..82645eb 100644 --- modules/node/node.test +++ modules/node/node.test @@ -350,7 +350,7 @@ class PageEditTestCase extends DrupalWebTestCase { // 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 DrupalWebTestCase { // 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.')); } } diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php index d817ef7..282ffd9 100644 --- modules/simpletest/drupal_web_test_case.php +++ modules/simpletest/drupal_web_test_case.php @@ -1237,6 +1237,15 @@ class DrupalWebTestCase { foreach ($elements as $element) { // SimpleXML objects need string casting all the time. $name = (string) $element['name']; + + // Ignore disabled elements, 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'])) { + unset($edit[$name]); + continue; + } + // This can either be the type of or the name of the tag itself // for