=== added file 'tests/poll_module.test' --- tests/poll_module.test 1970-01-01 00:00:00 +0000 +++ tests/poll_module.test 2007-12-31 12:18:59 +0000 @@ -0,0 +1,78 @@ + t('Poll create'), 'desc' => 'Adds "more choices", previews and creates a poll.', 'group' => 'Poll module tests'); + } + + function tearDown() { + parent::tearDown(); + } + + function testPollCreate($standalone = TRUE) { + $web_user = $this->drupalCreateUserRolePerm(array('create poll content')); + $this->drupalLoginUser($web_user); + $title = $this->randomName(); + $edit = array ( + 'title' => $title, + 'choice[0][chtext]' => 'choice 1', + 'choice[1][chtext]' => 'choice 2', + ); + $this->drupalPostRequest('node/add/poll', $edit, 'More choices'); + $edit = array( + 'title' => $title, + 'choice[0][chtext]' => 'choice 1', + 'choice[1][chtext]' => 'choice 2', + 'choice[2][chtext]' => 'choice 3', + 'choice[3][chtext]' => 'choice 4', + 'choice[4][chtext]' => 'choice 5', + 'choice[5][chtext]' => 'choice 6', + 'choice[6][chtext]' => 'choice 7', + ); + if ($standalone) { + $this->drupalPostRequest(NULL, $edit, 'Preview'); + for ($i = 0; $i <= 6; $i++) { + $bar = theme('poll_bar', $edit['choice['. $i .'][chtext]'], NULL, 0, FALSE, FALSE); + $this->assertTrue($bar, "bar $i is themed"); + file_put_contents('/tmp/t.txt', $this->_content); + file_put_contents('/tmp/t1.txt', $bar); + // $this->assertTrue(strpos($this->_content, $bar) !== FALSE, "bar $i found in preview"); + $this->assertWantedRaw($bar, "bar $i found in preview"); + } + } + $this->drupalPostRequest(NULL, $edit, 'Save'); + $this->nid = preg_replace('/\D/', '', $this->getUrl()); + $this->assertWantedRaw(t('@type %title has been created.', array('@type' => node_get_types('name', 'poll'), '%title' => $title)), 'Poll has been created.'); + } +} + +class pollVoteTest extends pollCreateTest { + /** + * Implementation of get_info() for information + */ + function get_info() { + return array('name' => t('Poll vote'), 'desc' => 'Vote on a poll', 'group' => 'Poll module tests'); + } + + function tearDown() { + parent::tearDown(); + } + + function testPollVote() { + $this->testPollCreate(FALSE); + $this->drupalGet(url('logout', array('absolute' => TRUE))); + $web_user = $this->drupalCreateUserRolePerm(array('cancel own vote', 'inspect all votes', 'vote on polls')); + $this->drupalLoginUser($web_user); + $edit = array ( + 'choice' => '1', + ); + $this->drupalPostRequest('node/'. $this->nid, $edit, 'Vote'); + $this->assertWantedRaw('Your vote was recorded.', 'Your vote was recorded.'); + $this->drupalGet(url("node/$this->nid/votes", array("absolute" => TRUE))); + $this->assertWantedRaw(t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.'), 'Vote table text.'); + $this->assertWantedRaw('choice 2', 'vote recorded'); + } +} === modified file 'drupal_test_case.php' --- drupal_test_case.php 2007-12-31 10:34:05 +0000 +++ drupal_test_case.php 2007-12-31 12:19:02 +0000 @@ -94,15 +94,23 @@ class DrupalTestCase extends WebTestCase * By $reporting you specify if this request does assertations or not * Warning: empty ("") returns will cause fails with $reporting * - * @param string $path location of the post form - * @param array $edit field data - * @param string $submit name of the submit button, untranslated + * @param string $path + * Location of the post form. Either a Drupal path or an absolute path or + * NULL to post to the current page. + * @param array $edit + * Field data in an assocative array. Changes the current input fields + * (where possible) to the values indicated. A checkbox can be set to + * TRUE to be checked and FALSE to be unchecked. + * @param string $submit + * Untranslated name of the submit button. */ function drupalPostRequest($path, $edit = array(), $submit) { - $url = url($path, array('absolute' => TRUE)); - $ret = $this->drupalGet($url); + if (isset($path)) { + $url = url($path, array('absolute' => TRUE)); + $ret = $this->drupalGet($url); + $this->assertTrue($ret, " [browser] GET $url"); + } - $this->assertTrue($ret, " [browser] GET $url"); foreach ($edit as $field_name => $field_value) { $ret = $this->_browser->setFieldByName($field_name, $field_value) || $this->_browser->setFieldById("edit-$field_name", $field_value); === modified file 'tests/node_revisions.test' --- tests/node_revisions.test 2007-12-31 10:35:03 +0000 +++ tests/node_revisions.test 2007-12-31 12:13:45 +0000 @@ -123,7 +123,7 @@ class NodeRevisionsTest extends DrupalTe * Cleanup function used by tests. Deletes the associated node. */ function cleanup($nid) { - node_delete(array('nid' => $nid)); + node_delete($nid); } } -?> \ No newline at end of file +?> === modified file 'tests/page_view.test' --- tests/page_view.test 2007-12-31 10:35:03 +0000 +++ tests/page_view.test 2007-12-31 12:13:57 +0000 @@ -53,6 +53,6 @@ class PageViewTest extends DrupalTestCas $test_user = $this->drupalCreateUserRolePerm(array('administer nodes')); //TODO: Add edit page attempt with administer nodes user - node_delete(array('nid' => $node->nid)); + node_delete($node->nid); } -} \ No newline at end of file +}