summaryrefslogtreecommitdiff
path: root/modules/poll/poll.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-21 00:43:42 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-21 00:43:42 +0000
commit59ceca0caf52002cf44206feec7c7213bc079939 (patch)
tree795bbe8ed9a00e4d55ce47516d5c6b4aa589c5e0 /modules/poll/poll.test
parent34119ba98b9e7b412ed7efdcf7b9e9b704f790c7 (diff)
downloadbrdo-59ceca0caf52002cf44206feec7c7213bc079939.tar.gz
brdo-59ceca0caf52002cf44206feec7c7213bc079939.tar.bz2
#633156 follow-up by effulgentsia and yched: Clean up AJAX tests, add sister function to drupal_js_encode().
Diffstat (limited to 'modules/poll/poll.test')
-rw-r--r--modules/poll/poll.test29
1 files changed, 5 insertions, 24 deletions
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index 2e976e5cb..3aa108901 100644
--- a/modules/poll/poll.test
+++ b/modules/poll/poll.test
@@ -339,30 +339,11 @@ class PollJSAddChoice extends DrupalWebTestCase {
'choice[new:1][chtext]' => $this->randomName(),
);
- // @TODO: the framework should make it possible to submit a form to a
- // different URL than its action or the current. For now, we can just force
- // it.
- $this->additionalCurlOptions[CURLOPT_URL] = url('system/ajax', array('absolute' => TRUE));
- $this->drupalPost(NULL, $edit, t('More choices'));
- unset($this->additionalCurlOptions[CURLOPT_URL]);
-
- // The response is drupal_json_output, so we need to undo some escaping.
- $commands = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
-
- // The JSON response will be two AJAX commands. The first is a settings
- // command and the second is the replace command.
- $settings = reset($commands);
- $replace = next($commands);
-
- $this->assertTrue(is_object($settings), t('The response settings command is an object'));
- $this->assertTrue(is_object($replace), t('The response replace command is an object'));
-
- // This replace data is valid HTML so we will can reuse everything we have
- // for HTML pages.
- $this->content = $replace->data;
-
- // Needs to be emptied out so the new content will be parsed.
- $this->elements = '';
+ // Press 'add choice' button through AJAX, and place the expected HTML result
+ // as the tested content.
+ $commands = $this->drupalPostAJAX(NULL, $edit, 'poll_more');
+ $this->content = $commands[1]['data'];
+
$this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], t('Field !i found', array('!i' => 0)));
$this->assertFieldByName('choice[chid:1][chtext]', $edit['choice[new:1][chtext]'], t('Field !i found', array('!i' => 1)));
$this->assertFieldByName('choice[new:0][chtext]', '', t('Field !i found', array('!i' => 2)));