From d7c32183e562eb8d1719da03869a0a1eb30227e8 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Thu, 26 Jun 2008 19:31:31 +0000 Subject: [PATCH] - Patch #275396 by Moshe: removed some dead code, and added url() options to drupalPost(). --- modules/simpletest/drupal_web_test_case.php | 29 +++++++++------------ 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index ef371234915e..e942f698c353 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -785,6 +785,7 @@ protected function parse() { if (!$this->elements) { $this->fail(t('Parsed page successfully.'), t('Browser')); } + return $this->elements; } @@ -822,32 +823,26 @@ function drupalGet($path, $options = array()) { * TRUE to be checked and FALSE to be unchecked. * @param $submit * Value of the submit button. - * @param $tamper - * If this is set to TRUE then you can post anything, otherwise hidden and - * nonexistent fields are not posted. + * @param $options + * Options to be forwarded to url(). */ - function drupalPost($path, $edit, $submit, $tamper = FALSE) { + function drupalPost($path, $edit, $submit, $options = array()) { $submit_matches = FALSE; if (isset($path)) { - $html = $this->drupalGet($path); + $html = $this->drupalGet($path, $options); } if ($this->parse()) { $edit_save = $edit; // Let's iterate over all the forms. $forms = $this->elements->xpath('//form'); foreach ($forms as $form) { - if ($tamper) { - // @TODO: this will be Drupal specific. One needs to add the build_id - // and the token to $edit then $post that. - } - else { - // We try to set the fields of this form as specified in $edit. - $edit = $edit_save; - $post = array(); - $upload = array(); - $submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form); - $action = isset($form['action']) ? $this->getAbsoluteUrl($form['action']) : $this->getUrl(); - } + // We try to set the fields of this form as specified in $edit. + $edit = $edit_save; + $post = array(); + $upload = array(); + $submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form); + $action = isset($form['action']) ? $this->getAbsoluteUrl($form['action']) : $this->getUrl(); + // We post only if we managed to handle every field in edit and the // submit button matches. if (!$edit && $submit_matches) { -- GitLab