diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-08-30 00:25:56 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-08-30 00:25:56 -0700 |
commit | 0e591faf2ad645715dad6cceabb8fcf9c0c35c87 (patch) | |
tree | 4899f591a6274bd265ea1d638b164cc9e15beaec /modules/poll | |
parent | 16b5120350eccb2f40c1eea6b2a854bdf9dc87bb (diff) | |
download | brdo-0e591faf2ad645715dad6cceabb8fcf9c0c35c87.tar.gz brdo-0e591faf2ad645715dad6cceabb8fcf9c0c35c87.tar.bz2 |
Issue #1214876 by brianV, Shyamala: Fixed Removing a poll choice doesn't actually work.
Diffstat (limited to 'modules/poll')
-rw-r--r-- | modules/poll/poll.module | 4 | ||||
-rw-r--r-- | modules/poll/poll.test | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 01c6bcc80..2737c2bd8 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -594,6 +594,10 @@ function poll_update($node) { ->condition('nid', $node->nid) ->condition('chid', $key) ->execute(); + db_delete('poll_choice') + ->condition('nid', $node->nid) + ->condition('chid', $choice['chid']) + ->execute(); } } } diff --git a/modules/poll/poll.test b/modules/poll/poll.test index d6c4f4005..d7648a6ba 100644 --- a/modules/poll/poll.test +++ b/modules/poll/poll.test @@ -746,3 +746,39 @@ class PollExpirationTestCase extends PollTestCase { $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), t('Poll has expired.')); } } + +class PollDeleteChoiceTestCase extends PollTestCase { + public static function getInfo() { + return array( + 'name' => 'Poll choice deletion', + 'description' => 'Test the poll choice deletion logic.', + 'group' => 'Poll', + ); + } + + function setUp() { + parent::setUp('poll'); + } + + function testChoiceRemoval() { + // Set up a poll with three choices. + $title = $this->randomName(); + $choices = array('First choice', 'Second choice', 'Third choice'); + $poll_nid = $this->pollCreate($title, $choices, FALSE); + $this->assertTrue($poll_nid, t('Poll for choice deletion logic test created.')); + + // Edit the poll, and try to delete first poll choice. + $this->drupalGet("node/$poll_nid/edit"); + $edit['choice[chid:1][chtext]'] = ''; + $this->drupalPost(NULL, $edit, t('Save')); + + // Click on the poll title to go to node page. + $this->drupalGet('poll'); + $this->clickLink($title); + + // Check the first poll choice is deleted, while the others remain. + $this->assertNoText('First choice', t('First choice removed.')); + $this->assertText('Second choice', t('Second choice remains.')); + $this->assertText('Third choice', t('Third choice remains.')); + } +} |