diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index ab03d41..d1cd0c0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -75,10 +75,9 @@ function testCommentEnable() { $this->resetAll(); $this->assertFalse(module_exists('comment'), 'Comment module disabled.'); - // Enable core content type modules (book, and poll). + // Enable core content type module (book). $edit = array(); $edit['modules[Core][book][enable]'] = 'book'; - $edit['modules[Core][poll][enable]'] = 'poll'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); // Now enable the comment module. @@ -90,7 +89,6 @@ function testCommentEnable() { // Create nodes of each type. $book_node = $this->drupalCreateNode(array('type' => 'book')); - $poll_node = $this->drupalCreateNode(array('type' => 'poll', 'active' => 1, 'runtime' => 0, 'choice' => array(array('chtext' => '')))); $this->drupalLogout(); @@ -100,7 +98,6 @@ function testCommentEnable() { $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval')); $this->drupalLogin($this->web_user); $this->postComment($book_node, $this->randomName(), $this->randomName()); - $this->postComment($poll_node, $this->randomName(), $this->randomName()); } /** diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php index ddfcac4..1769605 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php @@ -20,7 +20,7 @@ class DBLogTest extends WebTestBase { * * @var array */ - public static $modules = array('dblog', 'node', 'poll', 'help'); + public static $modules = array('dblog', 'node', 'forum', 'help'); /** * A user with some relevent administrative permissions. @@ -202,7 +202,7 @@ private function verifyEvents() { $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page'))); $this->doNode('article'); $this->doNode('page'); - $this->doNode('poll'); + $this->doNode('forum'); // When a user account is canceled, any content they created remains but the // uid = 0. Records in the watchdog table related to that user have the uid @@ -297,7 +297,7 @@ private function doUser() { * Generates and then verifies some node events. * * @param string $type - * A node type (e.g., 'article', 'page' or 'poll'). + * A node type (e.g., 'article', 'page' or 'forum'). */ private function doNode($type) { // Create user. @@ -369,11 +369,11 @@ private function doNode($type) { private function getContent($type) { $langcode = LANGUAGE_NOT_SPECIFIED; switch ($type) { - case 'poll': + case 'forum': $content = array( "title" => $this->randomName(8), - 'choice[new:0][chtext]' => $this->randomName(32), - 'choice[new:1][chtext]' => $this->randomName(32), + "taxonomy_forums[$langcode]" => array(1), + "body[$langcode][0][value]" => $this->randomName(32), ); break; @@ -397,21 +397,10 @@ private function getContent($type) { * Random content needed by various node types. */ private function getContentUpdate($type) { - switch ($type) { - case 'poll': - $content = array( - 'choice[chid:1][chtext]' => $this->randomName(32), - 'choice[chid:2][chtext]' => $this->randomName(32), - ); - break; - - default: - $langcode = LANGUAGE_NOT_SPECIFIED; - $content = array( - "body[$langcode][0][value]" => $this->randomName(32), - ); - break; - } + $langcode = LANGUAGE_NOT_SPECIFIED; + $content = array( + "body[$langcode][0][value]" => $this->randomName(32), + ); return $content; } diff --git a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php index dfaa71a..54b955f 100644 --- a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php +++ b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php @@ -19,7 +19,7 @@ class HelpTest extends WebTestBase { * * @var array. */ - public static $modules = array('poll'); + public static $modules = array('shortcut'); // Tests help implementations of many arbitrary core modules. protected $profile = 'standard'; diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php index 873c7ea..2821f7e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php @@ -12,14 +12,13 @@ /** * Tests basic options of multi-step node forms. */ -class MultiStepNodeFormBasicOptionsTest extends WebTestBase { +class MultiStepNodeFormBasicOptionsTest extends NodeTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('poll'); public static function getInfo() { return array( @@ -29,26 +28,52 @@ public static function getInfo() { ); } - function setUp() { - parent::setUp(); - - $web_user = $this->drupalCreateUser(array('administer nodes', 'create poll content')); - $this->drupalLogin($web_user); - } - /** * Tests changing the default values of basic options to ensure they persist. */ function testMultiStepNodeFormBasicOptions() { + // Prepare a user to create the node. + $web_user = $this->drupalCreateUser(array('administer nodes', 'create page content')); + $this->drupalLogin($web_user); + + // Create an unlimited cardinality field. + $this->field_name = drupal_strtolower($this->randomName()); + $this->field = array( + 'field_name' => drupal_strtolower($this->field_name), + 'type' => 'text', + 'cardinality' => -1, + ); + field_create_field($this->field); + + // Attach an instance of the field to the page content type. + $this->instance = array( + 'field_name' => $this->field_name, + 'entity_type' => 'node', + 'bundle' => 'page', + 'label' => $this->randomName() . '_label', + 'settings' => array( + 'text_processing' => TRUE, + ), + 'widget' => array( + 'type' => 'text_textfield', + ), + 'display' => array( + 'full' => array( + 'type' => 'text_default', + ), + ), + ); + field_create_instance($this->instance); + $langcode = LANGUAGE_NOT_SPECIFIED; + $edit = array( 'title' => 'a', 'status' => FALSE, 'promote' => FALSE, 'sticky' => 1, - 'choice[new:0][chtext]' => 'a', - 'choice[new:1][chtext]' => 'a', + "$this->field_name[$langcode][0][value]" => $this->randomString(32), ); - $this->drupalPost('node/add/poll', $edit, t('Add another choice')); + $this->drupalPost('node/add/page', $edit, t('Add another item')); $this->assertNoFieldChecked('edit-status', 'status stayed unchecked'); $this->assertNoFieldChecked('edit-promote', 'promote stayed unchecked'); $this->assertFieldChecked('edit-sticky', 'sticky stayed checked'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php index c51b5a0..d8fa419 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php @@ -11,6 +11,8 @@ * Test node type customizations persistence. */ class NodeTypePersistenceTest extends NodeTestBase { + // Enable the prerequisite modules for forum + public static $modules = array('history', 'taxonomy', 'options', 'comment'); public static function getInfo() { return array( 'name' => 'Node type persist', @@ -25,59 +27,59 @@ public static function getInfo() { function testNodeTypeCustomizationPersistence() { $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer modules')); $this->drupalLogin($web_user); - $poll_key = 'modules[Core][poll][enable]'; - $poll_enable = array($poll_key => "1"); - $poll_disable = array($poll_key => FALSE); + $forum_key = 'modules[Core][forum][enable]'; + $forum_enable = array($forum_key => "1"); + $forum_disable = array($forum_key => FALSE); - // Enable poll and verify that the node type is in the DB and is not + // Enable forum and verify that the node type is in the DB and is not // disabled. - $this->drupalPost('admin/modules', $poll_enable, t('Save configuration')); - $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'poll'))->fetchField(); - $this->assertNotIdentical($disabled, FALSE, 'Poll node type found in the database'); - $this->assertEqual($disabled, 0, 'Poll node type is not disabled'); + $this->drupalPost('admin/modules', $forum_enable, t('Save configuration')); + $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'forum'))->fetchField(); + $this->assertNotIdentical($disabled, FALSE, 'Forum node type found in the database'); + $this->assertEqual($disabled, 0, 'Forum node type is not disabled'); - // Check that poll node type (uncustomized) shows up. + // Check that forum node type (uncustomized) shows up. $this->drupalGet('node/add'); - $this->assertText('poll', 'poll type is found on node/add'); + $this->assertText('forum', 'forum type is found on node/add'); - // Customize poll description. + // Customize forum description. $description = $this->randomName(); $edit = array('description' => $description); - $this->drupalPost('admin/structure/types/manage/poll', $edit, t('Save content type')); + $this->drupalPost('admin/structure/types/manage/forum', $edit, t('Save content type')); - // Check that poll node type customization shows up. + // Check that forum node type customization shows up. $this->drupalGet('node/add'); $this->assertText($description, 'Customized description found'); - // Disable poll and check that the node type gets disabled. - $this->drupalPost('admin/modules', $poll_disable, t('Save configuration')); - $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'poll'))->fetchField(); - $this->assertEqual($disabled, 1, 'Poll node type is disabled'); + // Disable forum and check that the node type gets disabled. + $this->drupalPost('admin/modules', $forum_disable, t('Save configuration')); + $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'forum'))->fetchField(); + $this->assertEqual($disabled, 1, 'Forum node type is disabled'); $this->drupalGet('node/add'); - $this->assertNoText('poll', 'poll type is not found on node/add'); + $this->assertNoText('forum', 'forum type is not found on node/add'); - // Reenable poll and check that the customization survived the module + // Reenable forum and check that the customization survived the module // disable. - $this->drupalPost('admin/modules', $poll_enable, t('Save configuration')); - $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'poll'))->fetchField(); - $this->assertNotIdentical($disabled, FALSE, 'Poll node type found in the database'); - $this->assertEqual($disabled, 0, 'Poll node type is not disabled'); + $this->drupalPost('admin/modules', $forum_enable, t('Save configuration')); + $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'forum'))->fetchField(); + $this->assertNotIdentical($disabled, FALSE, 'Forum node type found in the database'); + $this->assertEqual($disabled, 0, 'Forum node type is not disabled'); $this->drupalGet('node/add'); $this->assertText($description, 'Customized description found'); - // Disable and uninstall poll. - $this->drupalPost('admin/modules', $poll_disable, t('Save configuration')); - $edit = array('uninstall[poll]' => 'poll'); + // Disable and uninstall forum. + $this->drupalPost('admin/modules', $forum_disable, t('Save configuration')); + $edit = array('uninstall[forum]' => 'forum'); $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall')); $this->drupalPost(NULL, array(), t('Uninstall')); - $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'poll'))->fetchField(); - $this->assertTrue($disabled, 'Poll node type is in the database and is disabled'); + $disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(':type' => 'forum'))->fetchField(); + $this->assertTrue($disabled, 'Forum node type is in the database and is disabled'); $this->drupalGet('node/add'); - $this->assertNoText('poll', 'poll type is no longer found on node/add'); + $this->assertNoText('forum', 'forum type is no longer found on node/add'); - // Reenable poll and check that the customization survived the module + // Reenable forum and check that the customization survived the module // uninstall. - $this->drupalPost('admin/modules', $poll_enable, t('Save configuration')); + $this->drupalPost('admin/modules', $forum_enable, t('Save configuration')); $this->drupalGet('node/add'); $this->assertText($description, 'Customized description is found even after uninstall and reenable.'); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php index 944af15..3d76f78 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php @@ -134,35 +134,28 @@ function testNodeTypeEditing() { */ function testNodeTypeStatus() { // Enable all core node modules, and all types should be active. - module_enable(array('book', 'poll'), FALSE); + module_enable(array('book'), FALSE); node_types_rebuild(); $types = node_type_get_types(); - foreach (array('book', 'poll', 'article', 'page') as $type) { + foreach (array('book', 'article', 'page') as $type) { $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type))); $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type))); } - // Disable poll module and the respective type should be marked as disabled. - module_disable(array('poll'), FALSE); - node_types_rebuild(); - $types = node_type_get_types(); - $this->assertTrue(!empty($types['poll']->disabled), "Poll module's node type disabled."); - // Disable book module and the respective type should still be active, since // it is not provided by hook_node_info(). module_disable(array('book'), FALSE); node_types_rebuild(); $types = node_type_get_types(); $this->assertTrue(isset($types['book']) && empty($types['book']->disabled), "Book module's node type still active."); - $this->assertTrue(!empty($types['poll']->disabled), "Poll module's node type still disabled."); $this->assertTrue(isset($types['article']) && empty($types['article']->disabled), 'Article node type still active.'); $this->assertTrue(isset($types['page']) && empty($types['page']->disabled), 'Basic page node type still active.'); // Re-enable the modules and verify that the types are active again. - module_enable(array('book', 'poll'), FALSE); + module_enable(array('book'), FALSE); node_types_rebuild(); $types = node_type_get_types(); - foreach (array('book', 'poll', 'article', 'page') as $type) { + foreach (array('book', 'article', 'page') as $type) { $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type))); $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type))); } diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php deleted file mode 100644 index 3febde0..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php +++ /dev/null @@ -1,89 +0,0 @@ - 'Block availability', - 'description' => 'Check if the most recent poll block is available.', - 'group' => 'Poll', - ); - } - - function setUp() { - parent::setUp(); - - // Create and login user - $admin_user = $this->drupalCreateUser(array('administer blocks')); - $this->drupalLogin($admin_user); - } - - /** - * Tests creating, viewing, voting on recent poll block. - */ - function testRecentBlock() { - // Set block title to confirm that the interface is available. - $this->drupalPost('admin/structure/block/manage/poll/recent/configure', array('title' => $this->randomName(8)), t('Save block')); - $this->assertText(t('The block configuration has been saved.'), 'Block configuration set.'); - - // Set the block to a region to confirm block is available. - $edit = array(); - $edit['blocks[poll_recent][region]'] = 'footer'; - $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.'); - - // Create a poll which should appear in recent polls block. - $title = $this->randomName(); - $choices = $this->_generateChoices(7); - $poll_nid = $this->pollCreate($title, $choices, TRUE); - - // Verify poll appears in a block. - // View user page so we're not matching the poll node on front page. - $this->drupalGet('user'); - // If a 'block' view not generated, this title would not appear even though - // the choices might. - $this->assertText($title, 'Poll appears in block.'); - - // Logout and login back in as a user who can vote. - $this->drupalLogout(); - $vote_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content')); - $this->drupalLogin($vote_user); - - // Verify we can vote via the block. - $edit = array( - 'choice' => '1', - ); - $this->drupalPost('user/' . $vote_user->uid, $edit, t('Vote')); - $this->assertText('Your vote was recorded.', 'Your vote was recorded.'); - $this->assertText('Total votes: 1', 'Vote count updated correctly.'); - $this->assertText('Older polls', 'Link to older polls appears.'); - $this->clickLink('Older polls'); - $this->assertText('1 vote - open', 'Link to poll listing correct.'); - - // Close the poll and verify block doesn't appear. - $content_user = $this->drupalCreateUser(array('create poll content', 'edit any poll content', 'access content')); - $this->drupalLogout(); - $this->drupalLogin($content_user); - $close_edit = array('active' => 0); - $this->pollUpdate($poll_nid, $title, $close_edit); - $this->drupalGet('user/' . $content_user->uid); - $this->assertNoText($title, 'Poll no longer appears in block.'); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php deleted file mode 100644 index 0618ce1..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php +++ /dev/null @@ -1,119 +0,0 @@ - 'Poll create', - 'description' => 'Adds "more choices", previews and creates a poll.', - 'group' => 'Poll' - ); - } - - /** - * Tests creating, listing, editing a new poll. - */ - function testPollCreate() { - $title = $this->randomName(); - $choices = $this->_generateChoices(7); - $poll_nid = $this->pollCreate($title, $choices, TRUE); - - // Verify poll appears on 'poll' page. - $this->drupalGet('poll'); - $this->assertText($title, 'Poll appears in poll list.'); - $this->assertText('open', 'Poll is active.'); - - // Click on the poll title to go to node page. - $this->clickLink($title); - $this->assertText('Total votes: 0', 'Link to poll correct.'); - - // Now add a new option to make sure that when we update the node the - // option is displayed. - $node = node_load($poll_nid); - - $new_option = $this->randomName(); - - $vote_count = '2000'; - $node->choice[] = array( - 'chid' => '', - 'chtext' => $new_option, - 'chvotes' => (int) $vote_count, - 'weight' => 1000, - ); - - $node->save(); - - $this->drupalGet('poll'); - $this->clickLink($title); - $this->assertText($new_option, 'New option found.'); - - $option = $this->xpath('//article[@id="node-1"]//div[@class="poll"]//dt[@class="choice-title"]'); - $this->assertEqual(end($option), $new_option, 'Last item is equal to new option.'); - - $votes = $this->xpath('//article[@id="node-1"]//div[@class="poll"]//div[@class="percent"]'); - $this->assertTrue(strpos(end($votes), $vote_count) > 0, "Votes saved."); - } - - /** - * Tests creating, editing, and closing a poll. - */ - function testPollClose() { - $content_user = $this->drupalCreateUser(array('create poll content', 'edit any poll content', 'access content')); - $vote_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content')); - - // Create poll. - $title = $this->randomName(); - $choices = $this->_generateChoices(7); - $poll_nid = $this->pollCreate($title, $choices, FALSE); - - $this->drupalLogout(); - $this->drupalLogin($content_user); - - // Edit the poll node and close the poll. - $close_edit = array('active' => 0); - $this->pollUpdate($poll_nid, $title, $close_edit); - - // Verify 'Vote' button no longer appears. - $this->drupalGet('node/' . $poll_nid); - $elements = $this->xpath('//input[@id="edit-vote"]'); - $this->assertTrue(empty($elements), "Vote button doesn't appear."); - - // Verify status on 'poll' page is 'closed'. - $this->drupalGet('poll'); - $this->assertText($title, 'Poll appears in poll list.'); - $this->assertText('closed', 'Poll is closed.'); - - // Edit the poll node and re-activate. - $open_edit = array('active' => 1); - $this->pollUpdate($poll_nid, $title, $open_edit); - - // Vote on the poll. - $this->drupalLogout(); - $this->drupalLogin($vote_user); - $vote_edit = array('choice' => '1'); - $this->drupalPost('node/' . $poll_nid, $vote_edit, t('Vote')); - $this->assertText('Your vote was recorded.', 'Your vote was recorded.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(isset($elements[0]), "'Cancel your vote' button appears."); - - // Edit the poll node and close the poll. - $this->drupalLogout(); - $this->drupalLogin($content_user); - $close_edit = array('active' => 0); - $this->pollUpdate($poll_nid, $title, $close_edit); - - // Verify 'Cancel your vote' button no longer appears. - $this->drupalGet('node/' . $poll_nid); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(empty($elements), "'Cancel your vote' button no longer appears."); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php deleted file mode 100644 index ccbd044..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Poll choice deletion', - 'description' => 'Test the poll choice deletion logic.', - 'group' => 'Poll', - ); - } - - /** - * Tests removing a choice from a 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, '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', 'First choice removed.'); - $this->assertText('Second choice', 'Second choice remains.'); - $this->assertText('Third choice', 'Third choice remains.'); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php deleted file mode 100644 index 2cfe9e5..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php +++ /dev/null @@ -1,73 +0,0 @@ - 'Poll expiration', - 'description' => 'Test the poll auto-expiration logic.', - 'group' => 'Poll', - ); - } - - /** - * Tests the expiration of a poll. - */ - function testAutoExpire() { - // Set up a poll. - $title = $this->randomName(); - $choices = $this->_generateChoices(2); - $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->assertTrue($poll_nid, 'Poll for auto-expire test created.'); - - // Visit the poll edit page and verify that by default, expiration - // is set to unlimited. - $this->drupalGet("node/$poll_nid/edit"); - $this->assertField('runtime', 'Poll expiration setting found.'); - $elements = $this->xpath('//select[@id="edit-runtime"]/option[@selected="selected"]'); - $this->assertTrue(isset($elements[0]['value']) && $elements[0]['value'] == 0, 'Poll expiration set to unlimited.'); - - // Set the expiration to one week. - $edit = array(); - $poll_expiration = 604800; // One week. - $edit['runtime'] = $poll_expiration; - $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('Poll %title has been updated.', array('%title' => $title)), 'Poll expiration settings saved.'); - - // Make sure that the changed expiration settings is kept. - $this->drupalGet("node/$poll_nid/edit"); - $elements = $this->xpath('//select[@id="edit-runtime"]/option[@selected="selected"]'); - $this->assertTrue(isset($elements[0]['value']) && $elements[0]['value'] == $poll_expiration, 'Poll expiration set to unlimited.'); - - // Force a cron run. Since the expiration date has not yet been reached, - // the poll should remain active. - drupal_cron_run(); - $this->drupalGet("node/$poll_nid/edit"); - $elements = $this->xpath('//input[@id="edit-active-1"]'); - $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), 'Poll is still active.'); - - // Test expiration. Since REQUEST_TIME is a constant and we don't - // want to keep SimpleTest waiting until the moment of expiration arrives, - // we forcibly change the expiration date in the database. - $created = db_query('SELECT created FROM {node} WHERE nid = :nid', array(':nid' => $poll_nid))->fetchField(); - db_update('node') - ->fields(array('created' => $created - ($poll_expiration * 1.01))) - ->condition('nid', $poll_nid) - ->execute(); - - // Run cron and verify that the poll is now marked as "closed". - drupal_cron_run(); - $this->drupalGet("node/$poll_nid/edit"); - $elements = $this->xpath('//input[@id="edit-active-0"]'); - $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), 'Poll has expired.'); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php deleted file mode 100644 index 88acc3b..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php +++ /dev/null @@ -1,54 +0,0 @@ - 'Poll add choice', - 'description' => 'Submits a POST request for an additional poll choice.', - 'group' => 'Poll' - ); - } - - /** - * Tests adding a new choice to a poll. - */ - function testAddChoice() { - $web_user = $this->drupalCreateUser(array('create poll content', 'access content')); - $this->drupalLogin($web_user); - $this->drupalGet('node/add/poll'); - $edit = array( - "title" => $this->randomName(), - 'choice[new:0][chtext]' => $this->randomName(), - 'choice[new:1][chtext]' => $this->randomName(), - ); - - // Press 'add choice' button through Ajax, and place the expected HTML result - // as the tested content. - $commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('Add another choice'))); - $this->content = $commands[1]['data']; - - $this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], format_string('Field !i found', array('!i' => 0))); - $this->assertFieldByName('choice[chid:1][chtext]', $edit['choice[new:1][chtext]'], format_string('Field !i found', array('!i' => 1))); - $this->assertFieldByName('choice[new:0][chtext]', '', format_string('Field !i found', array('!i' => 2))); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php deleted file mode 100644 index 94da1ef..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php +++ /dev/null @@ -1,202 +0,0 @@ -assertTrue(TRUE, 'Create a poll'); - - $admin_user = $this->drupalCreateUser(array('create poll content', 'administer nodes')); - $web_user = $this->drupalCreateUser(array('create poll content', 'access content', 'edit own poll content')); - $this->drupalLogin($admin_user); - - // Get the form first to initialize the state of the internal browser. - $this->drupalGet('node/add/poll'); - - // Prepare a form with two choices. - list($edit, $index) = $this->_pollGenerateEdit($title, $choices); - - // Verify that the vote count element only allows non-negative integers. - $edit['choice[new:1][chvotes]'] = -1; - $edit['choice[new:0][chvotes]'] = $this->randomString(7); - $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText(t('Vote count for new choice must be higher or equal to 0.')); - $this->assertText(t('Vote count for new choice must be a number.')); - - // Repeat steps for initializing the state of the internal browser. - $this->drupalLogin($web_user); - $this->drupalGet('node/add/poll'); - list($edit, $index) = $this->_pollGenerateEdit($title, $choices); - - // Re-submit the form until all choices are filled in. - if (count($choices) > 2) { - while ($index < count($choices)) { - $this->drupalPost(NULL, $edit, t('Add another choice')); - $this->assertPollChoiceOrder($choices, $index); - list($edit, $index) = $this->_pollGenerateEdit($title, $choices, $index); - } - } - - if ($preview) { - $this->drupalPost(NULL, $edit, t('Preview')); - $this->assertPollChoiceOrder($choices, $index, TRUE); - list($edit, $index) = $this->_pollGenerateEdit($title, $choices, $index); - } - - $this->drupalPost(NULL, $edit, t('Save')); - $node = $this->drupalGetNodeByTitle($title); - $this->assertText(t('@type @title has been created.', array('@type' => node_type_get_label('poll'), '@title' => $title)), 'Poll has been created.'); - $this->assertTrue($node->nid, 'Poll has been found in the database.'); - - return isset($node->nid) ? $node->nid : FALSE; - } - - /** - * Generates POST values for the poll node form, specifically poll choices. - * - * @param $title - * The title for the poll node. - * @param $choices - * An array containing poll choices, as generated by - * PollTestBase::_generateChoices(). - * @param $index - * (optional) The amount/number of already submitted poll choices. Defaults - * to 0. - * - * @return - * An indexed array containing: - * - The generated POST values, suitable for - * Drupal\simpletest\WebTestBase::drupalPost(). - * - The number of poll choices contained in 'edit', for potential re-usage - * in subsequent invocations of this function. - */ - function _pollGenerateEdit($title, array $choices, $index = 0) { - $max_new_choices = ($index == 0 ? 2 : 1); - $already_submitted_choices = array_slice($choices, 0, $index); - $new_choices = array_values(array_slice($choices, $index, $max_new_choices)); - - $edit = array( - 'title' => $title, - ); - foreach ($already_submitted_choices as $k => $text) { - $edit['choice[chid:' . $k . '][chtext]'] = $text; - } - foreach ($new_choices as $k => $text) { - $edit['choice[new:' . $k . '][chtext]'] = $text; - } - return array($edit, count($already_submitted_choices) + count($new_choices)); - } - - /* - * Generates random choices for the poll. - */ - function _generateChoices($count = 7) { - $choices = array(); - for ($i = 1; $i <= $count; $i++) { - $choices[] = $this->randomName(); - } - return $choices; - } - - /** - * Asserts correct poll choice order in the node form after submission. - * - * Verifies both the order in the DOM and in the 'weight' form elements. - * - * @param $choices - * An array containing poll choices, as generated by - * PollTestBase::_generateChoices(). - * @param $index - * (optional) The amount/number of already submitted poll choices. Defaults - * to 0. - * @param $preview - * (optional) Whether to also check the poll preview. - * - * @see PollTestBase::_pollGenerateEdit() - */ - function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) { - $expected = array(); - $weight = 0; - foreach ($choices as $id => $label) { - if ($id < $index) { - // The expected weight of each choice is higher than the previous one. - $weight++; - // Directly assert the weight form element value for this choice. - $this->assertFieldByName('choice[chid:' . $id . '][weight]', $weight, format_string('Found choice @id with weight @weight.', array( - '@id' => $id, - '@weight' => $weight, - ))); - // Append to our (to be reversed) stack of labels. - $expected[$weight] = $label; - } - } - ksort($expected); - - // Verify DOM order of poll choices (i.e., #weight of form elements). - $elements = $this->xpath('//input[starts-with(@name, :prefix) and contains(@name, :suffix)]', array( - ':prefix' => 'choice[chid:', - ':suffix' => '][chtext]', - )); - $expected_order = $expected; - foreach ($elements as $element) { - $next_label = array_shift($expected_order); - $this->assertEqual((string) $element['value'], $next_label); - } - - // If requested, also verify DOM order in preview. - if ($preview) { - $elements = $this->xpath('//div[contains(@class, :teaser)]/descendant::div[@class=:text]', array( - ':teaser' => 'node-teaser', - ':text' => 'text', - )); - $expected_order = $expected; - foreach ($elements as $element) { - $next_label = array_shift($expected_order); - $this->assertEqual((string) $element, $next_label, format_string('Found choice @label in preview.', array( - '@label' => $next_label, - ))); - } - } - } - - /** - * Tests updating a poll. - */ - function pollUpdate($nid, $title, $edit) { - // Edit the poll node. - $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); - $this->assertText(t('@type @title has been updated.', array('@type' => node_type_get_label('poll'), '@title' => $title)), 'Poll has been updated.'); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php deleted file mode 100644 index 13f2f79..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php +++ /dev/null @@ -1,93 +0,0 @@ - 'Poll token replacement', - 'description' => 'Generates text using placeholders for dummy content to check poll token replacement.', - 'group' => 'Poll', - ); - } - - /** - * Creates a poll, then tests the tokens generated from it. - */ - function testPollTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); - - // Craete a poll with three choices. - $title = $this->randomName(); - $choices = $this->_generateChoices(3); - $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->drupalLogout(); - - // Create four users and have each of them vote. - $vote_user1 = $this->drupalCreateUser(array('vote on polls', 'access content')); - $this->drupalLogin($vote_user1); - $edit = array( - 'choice' => '1', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->drupalLogout(); - - $vote_user2 = $this->drupalCreateUser(array('vote on polls', 'access content')); - $this->drupalLogin($vote_user2); - $edit = array( - 'choice' => '1', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->drupalLogout(); - - $vote_user3 = $this->drupalCreateUser(array('vote on polls', 'access content')); - $this->drupalLogin($vote_user3); - $edit = array( - 'choice' => '2', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->drupalLogout(); - - $vote_user4 = $this->drupalCreateUser(array('vote on polls', 'access content')); - $this->drupalLogin($vote_user4); - $edit = array( - 'choice' => '3', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->drupalLogout(); - - $poll = node_load($poll_nid, TRUE); - - // Generate and test sanitized tokens. - $tests = array(); - $tests['[node:poll-votes]'] = 4; - $tests['[node:poll-winner]'] = filter_xss($poll->choice[1]['chtext']); - $tests['[node:poll-winner-votes]'] = 2; - $tests['[node:poll-winner-percent]'] = 50; - $tests['[node:poll-duration]'] = format_interval($poll->runtime, 1, $language_interface->langcode); - - // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); - - foreach ($tests as $input => $expected) { - $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode)); - $this->assertEqual($output, $expected, format_string('Sanitized poll token %token replaced.', array('%token' => $input))); - } - - // Generate and test unsanitized tokens. - $tests['[node:poll-winner]'] = $poll->choice[1]['chtext']; - - foreach ($tests as $input => $expected) { - $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized poll token %token replaced.', array('%token' => $input))); - } - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php deleted file mode 100644 index d1ce358..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php +++ /dev/null @@ -1,83 +0,0 @@ - 'Poll translation', - 'description' => 'Test the poll translation logic.', - 'group' => 'Poll', - ); - } - - /** - * Tests poll creation and translation. - * - * Checks that the choice names get copied from the original poll and that - * the vote count values are set to 0. - */ - function testPollTranslate() { - $admin_user = $this->drupalCreateUser(array('administer content types', 'administer languages', 'edit any poll content', 'create poll content', 'administer nodes', 'translate all content')); - - // Set up a poll with two choices. - $title = $this->randomName(); - $choices = array($this->randomName(), $this->randomName()); - $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->assertTrue($poll_nid, 'Poll for translation logic test created.'); - - $this->drupalLogout(); - $this->drupalLogin($admin_user); - - // Enable a second language. - $this->drupalGet('admin/config/regional/language'); - $edit = array(); - $edit['predefined_langcode'] = 'nl'; - $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertRaw(t('The language %language has been created and can now be used.', array('%language' => 'Dutch')), 'Language Dutch has been created.'); - - // Set "Poll" content type to use multilingual support with translation. - $this->drupalGet('admin/structure/types/manage/poll'); - $edit = array('language_configuration[language_hidden]' => FALSE, 'node_type_language_translation_enabled' => TRUE); - $this->drupalPost('admin/structure/types/manage/poll', $edit, t('Save content type')); - $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Poll')), 'Poll content type has been updated.'); - - // Edit poll. - $this->drupalGet("node/$poll_nid/edit"); - $edit = array(); - // Set the poll's first choice count to 200. - $edit['choice[chid:1][chvotes]'] = 200; - // Set the language to Dutch. - $edit['langcode'] = 'nl'; - $this->drupalPost(NULL, $edit, t('Save')); - - // Translate the Dutch poll. - $this->drupalGet('node/add/poll', array('query' => array('translation' => $poll_nid, 'target' => 'en'))); - - $dutch_poll = node_load($poll_nid); - - // Check that the vote count values didn't get copied from the Dutch poll - // and are set to 0. - $this->assertFieldByName('choice[chid:1][chvotes]', '0', ('Found choice with vote count 0')); - $this->assertFieldByName('choice[chid:2][chvotes]', '0', ('Found choice with vote count 0')); - // Check that the choice names got copied from the Dutch poll. - $this->assertFieldByName('choice[chid:1][chtext]', $dutch_poll->choice[1]['chtext'], format_string('Found choice with text @text', array('@text' => $dutch_poll->choice[1]['chtext']))); - $this->assertFieldByName('choice[chid:2][chtext]', $dutch_poll->choice[2]['chtext'], format_string('Found choice with text @text', array('@text' => $dutch_poll->choice[2]['chtext']))); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php deleted file mode 100644 index 8efc02c..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php +++ /dev/null @@ -1,152 +0,0 @@ - 'User poll vote capability.', - 'description' => 'Check that users and anonymous users from specified ip-address can only vote once.', - 'group' => 'Poll' - ); - } - - function setUp() { - parent::setUp(); - - // Create and login user. - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'create poll content')); - $this->drupalLogin($this->admin_user); - - // Allow anonymous users to vote on polls. - user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( - 'access content' => TRUE, - 'vote on polls' => TRUE, - 'cancel own vote' => TRUE, - )); - - // Enable page cache to verify that the result page is not saved in the - // cache when anonymous voting is allowed. - $config = config('system.performance'); - $config->set('cache.page.enabled', 1); - $config->save(); - - // Create poll. - $title = $this->randomName(); - $choices = $this->_generateChoices(3); - $this->poll_nid = $this->pollCreate($title, $choices, FALSE); - - $this->drupalLogout(); - - // Create web users. - $this->web_user1 = $this->drupalCreateUser(array('access content', 'vote on polls', 'cancel own vote')); - $this->web_user2 = $this->drupalCreateUser(array('access content', 'vote on polls')); - } - - /** - * Checks that anonymous users with the same IP address can only vote once. - * - * Also checks that authenticated users can only vote once, even when the - * user's IP address has changed. - */ - function testHostnamePollVote() { - // Login User1. - $this->drupalLogin($this->web_user1); - - $edit = array( - 'choice' => '1', - ); - - // User1 vote on Poll. - $this->drupalPost('node/' . $this->poll_nid, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user1->name))); - $this->assertText(t('Total votes: @votes', array('@votes' => 1)), 'Vote count updated correctly.'); - - // Check to make sure User1 cannot vote again. - $this->drupalGet('node/' . $this->poll_nid); - $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->web_user1->name))); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); - - // Logout User1. - $this->drupalLogout(); - - // Fill the page cache by requesting the poll. - $this->drupalGet('node/' . $this->poll_nid); - $this->assertEqual($this->drupalGetHeader('x-drupal-cache'), 'MISS', 'Page was cacheable but was not in the cache.'); - $this->drupalGet('node/' . $this->poll_nid); - $this->assertEqual($this->drupalGetHeader('x-drupal-cache'), 'HIT', 'Page was cached.'); - - // Anonymous user vote on Poll. - $this->drupalPost(NULL, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), 'Anonymous vote was recorded.'); - $this->assertText(t('Total votes: @votes', array('@votes' => 2)), 'Vote count updated correctly.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); - - // Check to make sure Anonymous user cannot vote again. - $this->drupalGet('node/' . $this->poll_nid); - $this->assertFalse($this->drupalGetHeader('x-drupal-cache'), 'Page was not cacheable.'); - $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), "Anonymous is not able to vote again."); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); - - // Login User2. - $this->drupalLogin($this->web_user2); - - // User2 vote on poll. - $this->drupalPost('node/' . $this->poll_nid, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user2->name))); - $this->assertText(t('Total votes: @votes', array('@votes' => 3)), 'Vote count updated correctly.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); - - // Logout User2. - $this->drupalLogout(); - - // Change host name for anonymous users. - db_update('poll_vote') - ->fields(array( - 'hostname' => '123.456.789.1', - )) - ->condition('hostname', '', '<>') - ->execute(); - - // Check to make sure Anonymous user can vote again with a new session after - // a hostname change. - $this->drupalGet('node/' . $this->poll_nid); - $this->assertEqual($this->drupalGetHeader('x-drupal-cache'), 'MISS', 'Page was cacheable but was not in the cache.'); - $this->drupalPost(NULL, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), format_string('%user vote was recorded.', array('%user' => $this->web_user2->name))); - $this->assertText(t('Total votes: @votes', array('@votes' => 4)), 'Vote count updated correctly.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); - - // Check to make sure Anonymous user cannot vote again with a new session, - // and that the vote from the previous session cannot be cancelledd. - $this->curlClose(); - $this->drupalGet('node/' . $this->poll_nid); - $this->assertEqual($this->drupalGetHeader('x-drupal-cache'), 'MISS', 'Page was cacheable but was not in the cache.'); - $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), 'Anonymous is not able to vote again.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); - - // Login User1. - $this->drupalLogin($this->web_user1); - - // Check to make sure User1 still cannot vote even after hostname changed. - $this->drupalGet('node/' . $this->poll_nid); - $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), format_string("%user is not able to vote again.", array('%user' => $this->web_user1->name))); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); - } -} diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php deleted file mode 100644 index b8a2585..0000000 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php +++ /dev/null @@ -1,86 +0,0 @@ - 'Poll vote', - 'description' => 'Vote on a poll', - 'group' => 'Poll' - ); - } - - function tearDown() { - parent::tearDown(); - } - - /** - * Tests voting on a poll. - */ - function testPollVote() { - $title = $this->randomName(); - $choices = $this->_generateChoices(7); - $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->drupalLogout(); - - $vote_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content')); - $restricted_vote_user = $this->drupalCreateUser(array('vote on polls', 'access content')); - - $this->drupalLogin($vote_user); - - // Record a vote for the first choice. - $edit = array( - 'choice' => '1', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->assertText('Your vote was recorded.', 'Your vote was recorded.'); - $this->assertText('Total votes: 1', 'Vote count updated correctly.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(isset($elements[0]), "'Cancel your vote' button appears."); - - $this->drupalGet("node/$poll_nid/votes"); - $this->assertText(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->assertText($choices[0], 'Vote recorded'); - - // Ensure poll listing page has correct number of votes. - $this->drupalGet('poll'); - $this->assertText($title, 'Poll appears in poll list.'); - $this->assertText('1 vote', 'Poll has 1 vote.'); - - // Cancel a vote. - $this->drupalPost('node/' . $poll_nid, array(), t('Cancel your vote')); - $this->assertText('Your vote was cancelled.', 'Your vote was cancelled.'); - $this->assertNoText('Cancel your vote', "Cancel vote button doesn't appear."); - - $this->drupalGet("node/$poll_nid/votes"); - $this->assertNoText($choices[0], 'Vote cancelled'); - - // Ensure poll listing page has correct number of votes. - $this->drupalGet('poll'); - $this->assertText($title, 'Poll appears in poll list.'); - $this->assertText('0 votes', 'Poll has 0 votes.'); - - // Log in as a user who can only vote on polls. - $this->drupalLogout(); - $this->drupalLogin($restricted_vote_user); - - // Vote on a poll. - $edit = array( - 'choice' => '1', - ); - $this->drupalPost('node/' . $poll_nid, $edit, t('Vote')); - $this->assertText('Your vote was recorded.', 'Your vote was recorded.'); - $this->assertText('Total votes: 1', 'Vote count updated correctly.'); - $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); - } -} diff --git a/core/modules/poll/poll.admin.css b/core/modules/poll/poll.admin.css deleted file mode 100644 index f118de3..0000000 --- a/core/modules/poll/poll.admin.css +++ /dev/null @@ -1,17 +0,0 @@ - -/** - * @file - * Admin stylesheet for the Poll module. - */ - -.node-form #edit-poll-more { - margin: 0; -} -.node-form #poll-choice-table .form-text { - display: inline; - width: auto; -} -.node-form #poll-choice-table td.choice-flag { - white-space: nowrap; - width: 4em; -} diff --git a/core/modules/poll/poll.base-rtl.css b/core/modules/poll/poll.base-rtl.css deleted file mode 100644 index 7c737a9..0000000 --- a/core/modules/poll/poll.base-rtl.css +++ /dev/null @@ -1,9 +0,0 @@ - -/** - * @file - * Right-to-left specfic base stylesheet for the Poll module. - */ - -.poll .bar .foreground { - float: right; -} diff --git a/core/modules/poll/poll.base.css b/core/modules/poll/poll.base.css deleted file mode 100644 index 1d24c67..0000000 --- a/core/modules/poll/poll.base.css +++ /dev/null @@ -1,19 +0,0 @@ - -/** - * @file - * Base stylesheet for the Poll module. - */ - -.poll { - overflow: hidden; -} -.poll .bar { - height: 1em; - margin: 1px 0; - background-color: #ddd; -} -.poll .bar .foreground { - background-color: #000; - height: 1em; - float: left; /* LTR */ -} diff --git a/core/modules/poll/poll.info b/core/modules/poll/poll.info deleted file mode 100644 index 7cd674a..0000000 --- a/core/modules/poll/poll.info +++ /dev/null @@ -1,8 +0,0 @@ -name = Poll -description = Allows your site to capture votes on different topics in the form of multiple choice questions. -package = Core -version = VERSION -core = 8.x -dependencies[] = node -stylesheets[all][] = poll.base.css -stylesheets[all][] = poll.theme.css diff --git a/core/modules/poll/poll.install b/core/modules/poll/poll.install deleted file mode 100644 index 75896bb..0000000 --- a/core/modules/poll/poll.install +++ /dev/null @@ -1,149 +0,0 @@ - 'Stores poll-specific information for poll nodes.', - 'fields' => array( - 'nid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => "The poll's {node}.nid.", - ), - 'runtime' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The number of seconds past {node}.created during which the poll is open.', - ), - 'active' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Boolean indicating whether or not the poll is open.', - ), - ), - 'primary key' => array('nid'), - 'foreign keys' => array( - 'poll_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - ), - ); - - $schema['poll_choice'] = array( - 'description' => 'Stores information about all choices for all {poll}s.', - 'fields' => array( - 'chid' => array( - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'description' => 'Unique identifier for a poll choice.', - ), - 'nid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {node}.nid this choice belongs to.', - ), - 'chtext' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The text for this choice.', - 'translatable' => TRUE, - ), - 'chvotes' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The total number of votes this choice has received by all users.', - ), - 'weight' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The sort order of this choice among all choices for the same node.', - ), - ), - 'indexes' => array( - 'nid' => array('nid'), - ), - 'primary key' => array('chid'), - 'foreign keys' => array( - 'choice_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - ), - ); - - $schema['poll_vote'] = array( - 'description' => 'Stores per-{users} votes for each {poll}.', - 'fields' => array( - 'chid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'description' => "The {users}'s vote for this poll.", - ), - 'nid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'description' => 'The {poll} node this vote is for.', - ), - 'uid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The {users}.uid this vote is from unless the voter was anonymous.', - ), - 'hostname' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The IP address this vote is from unless the voter was logged in.', - ), - 'timestamp' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The timestamp of the vote creation.', - ), - ), - 'primary key' => array('nid', 'uid', 'hostname'), - 'foreign keys' => array( - 'poll_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'voter' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - 'indexes' => array( - 'chid' => array('chid'), - 'hostname' => array('hostname'), - 'uid' => array('uid'), - ), - ); - - return $schema; -} diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module deleted file mode 100644 index 6573218..0000000 --- a/core/modules/poll/poll.module +++ /dev/null @@ -1,1044 +0,0 @@ -' . t('About') . ''; - $output .= '

' . t('The Poll module can be used to create simple surveys or questionnaires that display cumulative results. A poll is a good way to receive feedback from site users and community members. For more information, see the online handbook entry for the Poll module.', array('@poll' => 'http://drupal.org/documentation/modules/poll/')) . '

'; - $output .= '

' . t('Uses') . '

'; - $output .= '
'; - $output .= '
' . t('Creating a poll') . '
'; - $output .= '
' . t('Users can create a poll by clicking on Poll on the Add new content page, and entering the question being posed, the answer choices, and beginning vote counts for each choice. The status (closed or active) and duration (length of time the poll remains active for new votes) can also be specified.', array('@add-content' => url('node/add'))) . '
'; - $output .= '
' . t('Viewing polls') . '
'; - $output .= '
' . t('You can visit the Polls page to view all current polls, or alternately enable the Most recent poll block on the Blocks administration page. To vote in or view the results of a specific poll, you can click on the poll itself.', array('@poll' => url('poll'), '@blocks' => url('admin/structure/block'))) . '
'; - $output .= '
'; - return $output; - } -} - -/** - * Implements hook_theme(). - */ -function poll_theme() { - $theme_hooks = array( - 'poll_vote' => array( - 'template' => 'poll-vote', - 'render element' => 'form', - ), - 'poll_choices' => array( - 'render element' => 'form', - ), - 'poll_results' => array( - 'template' => 'poll-results', - 'variables' => array('raw_title' => NULL, 'results' => NULL, 'votes' => NULL, 'raw_links' => NULL, 'block' => NULL, 'nid' => NULL, 'vote' => NULL), - ), - ); - - return $theme_hooks; -} - -/** - * Implements hook_permission(). - */ -function poll_permission() { - $perms = array( - 'vote on polls' => array( - 'title' => t('Vote on polls'), - ), - 'cancel own vote' => array( - 'title' => t('Cancel and change own votes'), - ), - 'inspect all votes' => array( - 'title' => t('View details for all votes'), - ), - ); - - return $perms; -} - -/** - * Implements hook_menu(). - */ -function poll_menu() { - $items['poll'] = array( - 'title' => 'Polls', - 'page callback' => 'poll_page', - 'access arguments' => array('access content'), - 'type' => MENU_SUGGESTED_ITEM, - 'file' => 'poll.pages.inc', - ); - - $items['node/%node/votes'] = array( - 'title' => 'Votes', - 'page callback' => 'poll_votes', - 'page arguments' => array(1), - 'access callback' => '_poll_menu_access', - 'access arguments' => array(1, 'inspect all votes', FALSE), - 'weight' => 3, - 'type' => MENU_LOCAL_TASK, - 'file' => 'poll.pages.inc', - ); - - $items['node/%node/results'] = array( - 'title' => 'Results', - 'page callback' => 'poll_results', - 'page arguments' => array(1), - 'access callback' => '_poll_menu_access', - 'access arguments' => array(1, 'access content', TRUE), - 'weight' => 3, - 'type' => MENU_LOCAL_TASK, - 'file' => 'poll.pages.inc', - ); - - return $items; -} - -/** - * Access callback: Determines if a node is acceptable for poll menu items. - * - * @param $node - * The poll node object. - * @param $perm - * A permission the user must have to view the page. - * @param $inspect_allowvotes - * TRUE if the user can view votes, and FALSE if the user cannot view votes. - */ -function _poll_menu_access($node, $perm, $inspect_allowvotes) { - return user_access($perm) && ($node->type == 'poll') && ($node->allowvotes || !$inspect_allowvotes); -} - -/** - * Implements hook_block_info(). - */ -function poll_block_info() { - $blocks['recent']['info'] = t('Most recent poll'); - $blocks['recent']['properties']['administrative'] = TRUE; - return $blocks; -} - -/** - * Implements hook_block_view(). - * - * Generates a block containing the latest poll. - * - * @see poll_block_latest_poll_view() - */ -function poll_block_view($delta = '') { - if (user_access('access content')) { - // Retrieve the latest poll. - $select = db_select('node', 'n'); - $select->join('poll', 'p', 'p.nid = n.nid'); - $select->fields('n', array('nid')) - ->condition('n.status', 1) - ->condition('p.active', 1) - ->orderBy('n.created', 'DESC') - ->range(0, 1) - ->addTag('node_access'); - - $record = $select->execute()->fetchObject(); - if ($record) { - $poll = node_load($record->nid); - if ($poll->nid) { - $poll = poll_block_latest_poll_view($poll); - $block['subject'] = t('Poll'); - $block['content'] = $poll->content; - return $block; - } - } - } -} - -/** - * Implements hook_cron(). - * - * Closes polls that have exceeded their allowed runtime. - */ -function poll_cron() { - $nids = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < :request_time AND p.active = :active AND p.runtime <> :runtime', array(':request_time' => REQUEST_TIME, ':active' => 1, ':runtime' => 0))->fetchCol(); - if (!empty($nids)) { - db_update('poll') - ->fields(array('active' => 0)) - ->condition('nid', $nids, 'IN') - ->execute(); - } -} - -/** - * Implements hook_node_info(). - */ -function poll_node_info() { - return array( - 'poll' => array( - 'name' => t('Poll'), - 'base' => 'poll', - 'description' => t('A poll is a question with a set of possible responses. A poll, once created, automatically provides a simple running count of the number of votes received for each response.'), - 'title_label' => t('Question'), - 'has_body' => FALSE, - ) - ); -} - -/** - * Implements hook_field_extra_fields(). - */ -function poll_field_extra_fields() { - $extra['node']['poll'] = array( - 'form' => array( - 'choice_wrapper' => array( - 'label' => t('Poll choices'), - 'description' => t('Poll choices'), - 'weight' => -4, - ), - 'settings' => array( - 'label' => t('Poll settings'), - 'description' => t('Poll module settings'), - 'weight' => -3, - ), - ), - 'display' => array( - 'poll_view_voting' => array( - 'label' => t('Poll vote'), - 'description' => t('Poll vote'), - 'weight' => 0, - ), - 'poll_view_results' => array( - 'label' => t('Poll results'), - 'description' => t('Poll results'), - 'weight' => 0, - ), - ) - ); - - return $extra; -} - -/** - * Implements hook_form(). - */ -function poll_form(Node $node, &$form_state) { - global $user; - - $admin = user_access('bypass node access') || user_access('edit any poll content') || (user_access('edit own poll content') && $user->uid == $node->uid); - - $type = node_type_load($node->type); - - // The submit handlers to add more poll choices require that this form is - // cached, regardless of whether Ajax is used. - $form_state['cache'] = TRUE; - - $form['title'] = array( - '#type' => 'textfield', - '#title' => check_plain($type->title_label), - '#required' => TRUE, - '#default_value' => $node->title, - '#weight' => -5, - ); - - if (isset($form_state['choice_count'])) { - $choice_count = $form_state['choice_count']; - } - else { - $choice_count = max(2, empty($node->choice) ? 2 : count($node->choice)); - } - - // Add a wrapper for the choices and more button. - $form['choice_wrapper'] = array( - '#tree' => FALSE, - '#weight' => -4, - '#prefix' => '
', - '#suffix' => '
', - ); - - // Container for just the poll choices. - $form['choice_wrapper']['choice'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#theme' => 'poll_choices', - ); - - // Add the current choices to the form. - $delta = 0; - $weight = 0; - if (isset($node->choice)) { - $delta = count($node->choice); - foreach ($node->choice as $chid => $choice) { - $key = 'chid:' . $chid; - $form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, $choice['chid'], $choice['chtext'], $choice['chvotes'], $choice['weight'], $choice_count); - $weight = max($choice['weight'], $weight); - } - } - - // Add initial or additional choices. - $existing_delta = $delta; - for ($delta; $delta < $choice_count; $delta++) { - $key = 'new:' . ($delta - $existing_delta); - // Increase the weight of each new choice. - $weight++; - $form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, NULL, '', 0, $weight, $choice_count); - } - - // We name our button 'poll_more' to avoid conflicts with other modules using - // Ajax-enabled buttons with the id 'more'. - $form['choice_wrapper']['poll_more'] = array( - '#type' => 'submit', - '#value' => t('Add another choice'), - '#weight' => 1, - '#limit_validation_errors' => array(array('choice')), - '#submit' => array('poll_more_choices_submit'), - '#ajax' => array( - 'callback' => 'poll_choice_js', - 'wrapper' => 'poll-choices', - 'effect' => 'fade', - ), - ); - - // Poll attributes - $duration = array( - // 1-6 days. - 86400, 2 * 86400, 3 * 86400, 4 * 86400, 5 * 86400, 6 * 86400, - // 1-3 weeks (7 days). - 604800, 2 * 604800, 3 * 604800, - // 1-3,6,9 months (30 days). - 2592000, 2 * 2592000, 3 * 2592000, 6 * 2592000, 9 * 2592000, - // 1 year (365 days). - 31536000, - ); - $duration = array(0 => t('Unlimited')) + drupal_map_assoc($duration, 'format_interval'); - $active = array(0 => t('Closed'), 1 => t('Active')); - - $form['settings'] = array( - '#type' => 'details', - '#collapsible' => TRUE, - '#title' => t('Poll settings'), - '#weight' => -3, - '#access' => $admin, - ); - - $form['settings']['active'] = array( - '#type' => 'radios', - '#title' => t('Poll status'), - '#default_value' => isset($node->active) ? $node->active : 1, - '#options' => $active, - '#description' => t('When a poll is closed, visitors can no longer vote for it.'), - '#access' => $admin, - ); - $form['settings']['runtime'] = array( - '#type' => 'select', - '#title' => t('Poll duration'), - '#default_value' => isset($node->runtime) ? $node->runtime : 0, - '#options' => $duration, - '#description' => t('After this period, the poll will be closed automatically.'), - ); - $form['#attached']['css'] = array( - drupal_get_path('module', 'poll') . '/poll.admin.css', - ); - - $form['#entity_builders'][] = 'poll_node_form_submit'; - - return $form; -} - -/** - * Form submission handler for adding more than two choices to a poll. - * - * This handler is run regardless of whether JavaScript is enabled. It makes - * changes to the form state. If the button is clicked with JavaScript - * disabled, then the page is reloaded with the complete rebuilt form. If the - * button was clicked with JavaScript enabled, then ajax_form_callback() calls - * poll_choice_js() to return just the changed part of the form. - */ -function poll_more_choices_submit($form, &$form_state) { - // Add one more choice to the form. - if ($form_state['values']['poll_more']) { - $form_state['choice_count'] = count($form_state['values']['choice']) + 1; - } - // Renumber the choices. This invalidates the corresponding key/value - // associations in $form_state['input'], so clear that out. This requires - // poll_form() to rebuild the choices with the values in $node->choice, which - // it does. - $node = $form_state['controller']->getEntity($form_state); - $node->choice = array_values($form_state['values']['choice']); - unset($form_state['input']['choice']); - $form_state['rebuild'] = TRUE; -} - -/** - * Constructs one individual form choice as part of poll node form. - * - * @see poll_form() - */ -function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10) { - $form = array( - '#tree' => TRUE, - '#weight' => $weight, - ); - - // We'll manually set the #parents property of these fields so that - // their values appear in the $form_state['values']['choice'] array. - $form['chid'] = array( - '#type' => 'value', - '#value' => $chid, - '#parents' => array('choice', $key, 'chid'), - ); - - $form['chtext'] = array( - '#type' => 'textfield', - '#title' => $value !== '' ? t('Choice label') : t('New choice label'), - '#title_display' => 'invisible', - '#default_value' => $value, - '#parents' => array('choice', $key, 'chtext'), - ); - - $form['chvotes'] = array( - '#type' => 'number', - '#title' => $value !== '' ? t('Vote count for choice @label', array('@label' => $value)) : t('Vote count for new choice'), - '#title_display' => 'invisible', - '#default_value' => $votes, - '#min' => 0, - '#parents' => array('choice', $key, 'chvotes'), - '#access' => user_access('administer nodes'), - ); - - $form['weight'] = array( - '#type' => 'weight', - '#title' => $value !== '' ? t('Weight for choice @label', array('@label' => $value)) : t('Weight for new choice'), - '#title_display' => 'invisible', - '#default_value' => $weight, - '#delta' => $size, - '#parents' => array('choice', $key, 'weight'), - ); - - return $form; -} - -/** - * Ajax callback for adding new choices to the poll node form. - * - * This returns the new page content to replace the page content made obsolete - * by the form submission. - */ -function poll_choice_js($form, $form_state) { - return $form['choice_wrapper']['choice']; -} - -/** - * Entity builder for node_form(). - * - * Upon preview and final submission, we need to renumber poll choices and - * create a teaser output. - * - * @see poll_teaser() - */ -function poll_node_form_submit($entity_type, $entity, &$form, &$form_state) { - // Renumber choices. - $entity->choice = array_values($form_state['values']['choice']); - $form_state['values']['teaser'] = poll_teaser((object) $form_state['values']); -} - -/** - * Implements hook_validate(). - */ -function poll_validate($node, $form) { - if ($node->label()) { - // Check for at least two options and validate amount of votes. - $realchoices = 0; - foreach ($node->choice as $i => $choice) { - if ($choice['chtext'] != '') { - $realchoices++; - } - } - - if ($realchoices < 2) { - form_set_error("choice][$realchoices][chtext", t('You must fill in at least two choices.')); - } - } -} - -/** - * Implements hook_field_attach_prepare_translation_alter(). - */ -function poll_field_attach_prepare_translation_alter(&$entity, $context) { - if ($context['entity_type'] == 'node' && $entity->type == 'poll') { - $entity->choice = $context['source_entity']->choice; - foreach ($entity->choice as $i => $choice) { - $entity->choice[$i]['chvotes'] = 0; - } - } -} - -/** - * Implements hook_load(). - */ -function poll_load($nodes) { - global $user; - foreach ($nodes as $node) { - $poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject(); - - if (empty($poll)) { - $poll = new stdClass(); - } - - // Load the appropriate choices into the $poll object. - $poll->choice = db_select('poll_choice', 'c') - ->addTag('translatable') - ->fields('c', array('chid', 'chtext', 'chvotes', 'weight')) - ->condition('c.nid', $node->nid) - ->orderBy('weight') - ->execute()->fetchAllAssoc('chid', PDO::FETCH_ASSOC); - - // Determine whether or not this user is allowed to vote. - $poll->allowvotes = FALSE; - if (user_access('vote on polls') && $poll->active) { - if ($user->uid) { - // If authenticated, find existing vote based on uid. - $poll->vote = db_query('SELECT chid FROM {poll_vote} WHERE nid = :nid AND uid = :uid', array(':nid' => $node->nid, ':uid' => $user->uid))->fetchField(); - if (empty($poll->vote)) { - $poll->vote = -1; - $poll->allowvotes = TRUE; - } - } - elseif (!empty($_SESSION['poll_vote'][$node->nid])) { - // Otherwise the user is anonymous. Look for an existing vote in the - // user's session. - $poll->vote = $_SESSION['poll_vote'][$node->nid]; - } - else { - // Finally, query the database for an existing vote based on anonymous - // user's hostname. - $poll->allowvotes = !db_query("SELECT 1 FROM {poll_vote} WHERE nid = :nid AND hostname = :hostname AND uid = 0", array(':nid' => $node->nid, ':hostname' => ip_address()))->fetchField(); - } - } - foreach ($poll as $key => $value) { - $nodes[$node->nid]->$key = $value; - } - } -} - -/** - * Implements hook_insert(). - */ -function poll_insert($node) { - if (!user_access('administer nodes')) { - // Make sure all votes are 0 initially - foreach ($node->choice as $i => $choice) { - $node->choice[$i]['chvotes'] = 0; - } - $node->active = 1; - } - - db_insert('poll') - ->fields(array( - 'nid' => $node->nid, - 'runtime' => $node->runtime, - 'active' => $node->active, - )) - ->execute(); - - foreach ($node->choice as $choice) { - if ($choice['chtext'] != '') { - db_insert('poll_choice') - ->fields(array( - 'nid' => $node->nid, - 'chtext' => $choice['chtext'], - 'chvotes' => $choice['chvotes'], - 'weight' => $choice['weight'], - )) - ->execute(); - } - } -} - -/** - * Implements hook_update(). - */ -function poll_update($node) { - // Update poll settings. - db_update('poll') - ->fields(array( - 'runtime' => $node->runtime, - 'active' => $node->active, - )) - ->condition('nid', $node->nid) - ->execute(); - - // Poll choices with empty titles signifies removal. We remove all votes to - // the removed options, so people who voted on them can vote again. - foreach ($node->choice as $key => $choice) { - if (!empty($choice['chtext'])) { - db_merge('poll_choice') - ->key(array('chid' => $choice['chid'])) - ->fields(array( - 'chtext' => $choice['chtext'], - 'chvotes' => (int) $choice['chvotes'], - 'weight' => $choice['weight'], - )) - ->insertFields(array( - 'nid' => $node->nid, - 'chtext' => $choice['chtext'], - 'chvotes' => (int) $choice['chvotes'], - 'weight' => $choice['weight'], - )) - ->execute(); - } - else { - db_delete('poll_vote') - ->condition('nid', $node->nid) - ->condition('chid', $key) - ->execute(); - db_delete('poll_choice') - ->condition('nid', $node->nid) - ->condition('chid', $choice['chid']) - ->execute(); - } - } -} - -/** - * Implements hook_delete(). - */ -function poll_delete($node) { - db_delete('poll') - ->condition('nid', $node->nid) - ->execute(); - db_delete('poll_choice') - ->condition('nid', $node->nid) - ->execute(); - db_delete('poll_vote') - ->condition('nid', $node->nid) - ->execute(); -} - -/** - * Returns the content for the 'latest poll' block. - * - * @param Drupal\node\Node $node - * The node entity to load. - * - * @see poll_view_results() - */ -function poll_block_latest_poll_view(Node $node) { - global $user; - $output = ''; - - // This is necessary for shared objects because PHP doesn't copy objects, but - // passes them by reference. So when the objects are cached it can result in - // the wrong output being displayed on subsequent calls. The cloning and - // unsetting of $node->content prevents the block output from being the same - // as the node output. - $node = clone $node; - unset($node->content); - - // No 'read more' link. - $node->readmore = FALSE; - $node->teaser = ''; - - $links = array(); - $links[] = array('title' => t('Older polls'), 'href' => 'poll', 'attributes' => array('title' => t('View the list of polls on this site.'))); - if ($node->allowvotes) { - $links[] = array('title' => t('Results'), 'href' => 'node/' . $node->nid . '/results', 'attributes' => array('title' => t('View the current poll results.'))); - } - - $node->links = $links; - - if (!empty($node->allowvotes)) { - $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node, TRUE); - $node->content['links'] = array( - '#theme' => 'links', - '#links' => $node->links, - '#weight' => 5, - ); - } - else { - $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, TRUE, TRUE)); - } - - return $node; -} - - -/** - * Implements hook_view(). - * - * @see poll_view_results() - */ -function poll_view($node, $view_mode) { - global $user; - $output = ''; - - if (!empty($node->allowvotes) && empty($node->show_results)) { - $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node); - } - else { - $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $view_mode)); - } - return $node; -} - -/** - * Creates a simple teaser that lists all the choices. - * - * This is primarily used for RSS. - * - * @param $node - * The poll node object. - * - * @return - * Poll choices in a simple teaser format. - */ -function poll_teaser($node) { - $teaser = NULL; - if (is_array($node->choice)) { - foreach ($node->choice as $k => $choice) { - if ($choice['chtext'] != '') { - $teaser .= '* ' . check_plain($choice['chtext']) . "\n"; - } - } - } - return $teaser; -} - -/** - * Form constructor for the poll voting form. - * - * @param $node - * The poll node object. - * @param $block - * (optional) TRUE if a poll should be displayed in a block. Defaults to - * FALSE. - * @see phptemplate_preprocess_poll_vote() - * @see poll_vote() - * @ingroup forms - */ -function poll_view_voting($form, &$form_state, $node, $block = FALSE) { - if ($node->choice) { - $list = array(); - foreach ($node->choice as $i => $choice) { - $list[$i] = check_plain($choice['chtext']); - } - $form['choice'] = array( - '#type' => 'radios', - '#title' => t('Choices'), - '#title_display' => 'invisible', - '#default_value' => -1, - '#options' => $list, - ); - } - - $form['vote'] = array( - '#type' => 'submit', - '#value' => t('Vote'), - '#submit' => array('poll_vote'), - ); - - // Store the node so we can get to it in submit functions. - $form['#node'] = $node; - $form['#block'] = $block; - - // Set form caching because we could have multiple of these forms on - // the same page, and we want to ensure the right one gets picked. - $form_state['cache'] = TRUE; - - // Provide a more cleanly named voting form theme. - $form['#theme'] = 'poll_vote'; - return $form; -} - -/** - * Form validation handler for poll_view_voting(). - * - * @see poll_vote() - */ -function poll_view_voting_validate($form, &$form_state) { - if ($form_state['values']['choice'] == -1) { - form_set_error( 'choice', t('Your vote could not be recorded because you did not select any of the choices.')); - } -} - -/** - * Form submission handler for poll_view_voting(). - * - * @see poll_view_voting_validate() - */ -function poll_vote($form, &$form_state) { - $node = $form['#node']; - $choice = $form_state['values']['choice']; - - global $user; - db_insert('poll_vote') - ->fields(array( - 'nid' => $node->nid, - 'chid' => $choice, - 'uid' => $user->uid, - 'hostname' => ip_address(), - 'timestamp' => REQUEST_TIME, - )) - ->execute(); - - // Add one to the votes. - db_update('poll_choice') - ->expression('chvotes', 'chvotes + 1') - ->condition('chid', $choice) - ->execute(); - - cache_invalidate_tags(array('content' => TRUE)); - - if (!$user->uid) { - // The vote is recorded so the user gets the result view instead of the - // voting form when viewing the poll. Saving a value in $_SESSION has the - // convenient side effect of preventing the user from hitting the page - // cache. When anonymous voting is allowed, the page cache should only - // contain the voting form, not the results. - $_SESSION['poll_vote'][$node->nid] = $choice; - } - - drupal_set_message(t('Your vote was recorded.')); - - // Return the user to whatever page they voted from. -} - -/** - * Implements hook_preprocess_HOOK() for block.tpl.php. - */ -function poll_preprocess_block(&$variables) { - if ($variables['block']->module == 'poll') { - $variables['attributes']['role'] = 'complementary'; - } -} - -/** - * Implements template_preprocess_HOOK() for poll-vote.tpl.php. - */ -function template_preprocess_poll_vote(&$variables) { - $form = $variables['form']; - $variables['choice'] = drupal_render($form['choice']); - $variables['title'] = check_plain($form['#node']->title); - $variables['vote'] = drupal_render($form['vote']); - $variables['rest'] = drupal_render_children($form); - $variables['block'] = $form['#block']; - if ($variables['block']) { - $variables['theme_hook_suggestions'][] = 'poll_vote__block'; - } -} - -/** - * Generates a graphical representation of the results of a poll. - * - * @see poll_block_latest_poll_view() - * @see poll_view() - */ -function poll_view_results($node, $view_mode, $block = FALSE) { - // Make sure that choices are ordered by their weight. - uasort($node->choice, 'drupal_sort_weight'); - - // Count the votes and find the maximum. - $total_votes = 0; - $max_votes = 0; - foreach ($node->choice as $choice) { - if (isset($choice['chvotes'])) { - $total_votes += $choice['chvotes']; - $max_votes = max($max_votes, $choice['chvotes']); - } - } - - $poll_results = array(); - foreach ($node->choice as $i => $choice) { - $chvotes = isset($choice['chvotes']) ? $choice['chvotes'] : NULL; - $percentage = round($chvotes * 100 / max($total_votes, 1)); - $display_votes = !$block ? ' (' . format_plural($chvotes, '1 vote', '@count votes') . ')' : ''; - - $poll_results[] = array( - '#theme' => 'meter', - '#prefix' => '
' . check_plain($choice['chtext']) . "
\n" . '
', - '#suffix' => "
\n", - '#display_value' => t('!percentage%', array('!percentage' => $percentage)) . $display_votes, - '#min' => 0, - '#max' => $total_votes, - '#value' => $chvotes, - '#percentage' => $percentage, - '#attributes' => array('class' => 'bar'), - ); - } - - return theme('poll_results', array('raw_title' => $node->label(), 'results' => drupal_render($poll_results), 'votes' => $total_votes, 'raw_links' => isset($node->links) ? $node->links : array(), 'block' => $block, 'nid' => $node->nid, 'vote' => isset($node->vote) ? $node->vote : NULL)); -} - - -/** - * Returns HTML for an admin poll form for choices. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_poll_choices($variables) { - $form = $variables['form']; - - drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight'); - - $is_admin= user_access('administer nodes'); - $delta = 0; - $rows = array(); - $headers = array('', t('Choice')); - if ($is_admin) { - $headers[] = t('Vote count'); - } - $headers[] = t('Weight'); - - foreach (element_children($form) as $key) { - $delta++; - // Set special classes for drag and drop updating. - $form[$key]['weight']['#attributes']['class'] = array('poll-weight'); - - // Build the table row. - $row = array( - 'data' => array( - array('class' => array('choice-flag')), - drupal_render($form[$key]['chtext']), - ), - 'class' => array('draggable'), - ); - if ($is_admin) { - $row['data'][] = drupal_render($form[$key]['chvotes']); - } - $row['data'][] = drupal_render($form[$key]['weight']); - - // Add any additional classes set on the row. - if (!empty($form[$key]['#attributes']['class'])) { - $row['class'] = array_merge($row['class'], $form[$key]['#attributes']['class']); - } - - $rows[] = $row; - } - - $output = theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => 'poll-choice-table'))); - $output .= drupal_render_children($form); - return $output; -} - -/** - * Implements template_preprocess_HOOK() for poll-results.tpl.php. - * - * @param $variables - * An associative array containing: - * - raw_title: A string for the title of the poll. - * - results: The results of the poll. - * - votes: The total results in the poll. - * - raw_links: Array containing links in the poll. - * - block: A boolean to define if the poll is a block. - * - nid: The node ID of the poll. - * - vote: The choice number of the current user's vote. - * The raw_* inputs to this are naturally unsafe; often safe versions are - * made to simply overwrite the raw version, but in this case it seems likely - * that the title and the links may be overridden by the theme layer, so they - * are left in with a different name for that purpose. - * - * @see poll-results.tpl.php - * @see poll-results--block.tpl.php - */ -function template_preprocess_poll_results(&$variables) { - $variables['links'] = theme('links__poll_results', array('links' => $variables['raw_links'])); - if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) { - $elements = drupal_get_form('poll_cancel_form', $variables['nid']); - $variables['cancel_form'] = drupal_render($elements); - } - $variables['title'] = check_plain($variables['raw_title']); -} - -/** - * Form constructor for the poll cancel form. - * - * @param $nid - * The poll node ID. - * - * @ingroup forms - * @see poll_cancel() - */ -function poll_cancel_form($form, &$form_state, $nid) { - $form_state['cache'] = TRUE; - - // Store the nid so we can get to it in submit functions. - $form['#nid'] = $nid; - - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Cancel your vote'), - '#submit' => array('poll_cancel') - ); - - return $form; -} - -/** - * Form submission handler for poll_cancel_form(). - */ -function poll_cancel($form, &$form_state) { - global $user; - $node = node_load($form['#nid']); - - db_delete('poll_vote') - ->condition('nid', $node->nid) - ->condition($user->uid ? 'uid' : 'hostname', $user->uid ? $user->uid : ip_address()) - ->execute(); - - // Subtract from the votes. - db_update('poll_choice') - ->expression('chvotes', 'chvotes - 1') - ->condition('chid', $node->vote) - ->execute(); - - unset($_SESSION['poll_vote'][$node->nid]); - - drupal_set_message(t('Your vote was cancelled.')); -} - -/** - * Implements hook_user_cancel(). - */ -function poll_user_cancel($edit, $account, $method) { - switch ($method) { - case 'user_cancel_reassign': - db_update('poll_vote') - ->fields(array('uid' => 0)) - ->condition('uid', $account->uid) - ->execute(); - break; - } -} - -/** - * Implements hook_user_predelete(). - */ -function poll_user_predelete($account) { - db_delete('poll_vote') - ->condition('uid', $account->uid) - ->execute(); -} - -/** - * Implements hook_rdf_mapping(). - */ -function poll_rdf_mapping() { - return array( - array( - 'type' => 'node', - 'bundle' => 'poll', - 'mapping' => array( - 'rdftype' => array('sioc:Post', 'sioct:Poll'), - ), - ), - ); -} diff --git a/core/modules/poll/poll.pages.inc b/core/modules/poll/poll.pages.inc deleted file mode 100644 index b67d8f9..0000000 --- a/core/modules/poll/poll.pages.inc +++ /dev/null @@ -1,125 +0,0 @@ -addExpression('COUNT(*)', 'expression'); - $count_select->join('poll', 'p', 'p.nid = n.nid'); - $count_select->condition('n.status', 1); - - // List all polls. - $select = db_select('node', 'n'); - $select->join('poll', 'p', 'p.nid = n.nid'); - $select->join('poll_choice', 'c', 'c.nid = n.nid'); - $select->addExpression('SUM(c.chvotes)', 'votes'); - $select = $select->fields('n', array('nid', 'title', 'created')) - ->fields('p', array('active')) - ->condition('n.status', 1) - ->orderBy('n.created', 'DESC') - ->groupBy('n.nid') - ->groupBy('n.title') - ->groupBy('p.active') - ->groupBy('n.created') - ->extend('Drupal\Core\Database\Query\PagerSelectExtender') - ->limit($polls_per_page) - ->addTag('node_access'); - $select->setCountQuery($count_select); - $queried_nodes = $select->execute() - ->fetchAllAssoc('nid'); - - $output = ''; - $output .= theme('pager'); - return $output; -} - -/** - * Page callback: Displays the 'votes' tab for polls. - * - * This page displays a table containing each vote that has been cast. - * - * @param $node - * The poll node object. - * - * @return - * Render array containing table with votes. - * - * @see poll_menu() - */ -function poll_votes($node) { - $votes_per_page = 20; - drupal_set_title($node->label()); - - $header[] = array('data' => t('Visitor'), 'field' => 'u.name'); - $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext'); - $header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc'); - - $select = db_select('poll_vote', 'pv') - ->extend('Drupal\Core\Database\Query\PagerSelectExtender') - ->extend('Drupal\Core\Database\Query\TableSortExtender'); - $select->join('poll_choice', 'pc', 'pv.chid = pc.chid'); - $select->join('users', 'u', 'pv.uid = u.uid'); - $queried_votes = $select - ->addTag('translatable') - ->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid')) - ->fields('pc', array('chtext')) - ->fields('u', array('name')) - ->condition('pv.nid', $node->nid) - ->limit($votes_per_page) - ->orderByHeader($header) - ->execute(); - - $rows = array(); - foreach ($queried_votes as $vote) { - $rows[] = array( - $vote->name ? theme('username', array('account' => $vote)) : check_plain($vote->hostname), - check_plain($vote->chtext), - format_date($vote->timestamp), - ); - } - $build['poll_votes_table'] = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - '#prefix' => 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.'), - ); - $build['poll_votes_pager'] = array('#theme' => 'pager'); - return $build; -} - -/** - * Page callback: Displays the 'results' tab for the current poll. - * - * This tab displays a summary of the votes that have been cast. - * - * @param $node - * The poll node object. - * - * @return - * An array suitable for use by drupal_render(). - * - * @see poll_menu() - */ -function poll_results($node) { - drupal_set_title($node->label()); - $node->show_results = TRUE; - return node_show($node); -} diff --git a/core/modules/poll/poll.theme-rtl.css b/core/modules/poll/poll.theme-rtl.css deleted file mode 100644 index 2ba85c6..0000000 --- a/core/modules/poll/poll.theme-rtl.css +++ /dev/null @@ -1,12 +0,0 @@ - -/** - * @file - * Right-to-left specfic theme stylesheet for the Poll module. - */ - -.poll .percent { - text-align: left; -} -.poll .vote-form { - text-align: right; -} diff --git a/core/modules/poll/poll.theme.css b/core/modules/poll/poll.theme.css deleted file mode 100644 index 3e91786..0000000 --- a/core/modules/poll/poll.theme.css +++ /dev/null @@ -1,34 +0,0 @@ - -/** - * @file - * Theme stylesheet for the Poll module. - */ - -.poll dl, -.poll dd { - margin: 0; -} -.poll .links { - text-align: center; -} -.poll .percent { - text-align: right; /* LTR */ -} -.poll .total { - text-align: center; -} -.poll .vote-form { - text-align: center; -} -.poll .vote-form { - text-align: left; /* LTR */ -} -.poll .vote-form .poll-title { - font-weight: bold; -} -td.poll-chtext { - width: 80%; -} -td.poll-chvotes .form-text { - width: 85%; -} diff --git a/core/modules/poll/poll.tokens.inc b/core/modules/poll/poll.tokens.inc deleted file mode 100644 index e0f9b2b..0000000 --- a/core/modules/poll/poll.tokens.inc +++ /dev/null @@ -1,107 +0,0 @@ - t("Poll votes"), - 'description' => t("The number of votes that have been cast on a poll."), - ); - $node['poll-winner'] = array( - 'name' => t("Poll winner"), - 'description' => t("The winning poll answer."), - ); - $node['poll-winner-votes'] = array( - 'name' => t("Poll winner votes"), - 'description' => t("The number of votes received by the winning poll answer."), - ); - $node['poll-winner-percent'] = array( - 'name' => t("Poll winner percent"), - 'description' => t("The percentage of votes received by the winning poll answer."), - ); - $node['poll-duration'] = array( - 'name' => t("Poll duration"), - 'description' => t("The length of time the poll is set to run."), - ); - - return array( - 'tokens' => array('node' => $node), - ); -} - -/** - * Implements hook_tokens(). - */ -function poll_tokens($type, $tokens, array $data = array(), array $options = array()) { - $sanitize = !empty($options['sanitize']); - if (isset($options['langcode'])) { - $url_options['language'] = language_load($options['langcode']); - $langcode = $options['langcode']; - } - else { - $langcode = NULL; - } - - $replacements = array(); - - if ($type == 'node' && !empty($data['node']) && $data['node']->type == 'poll') { - $node = $data['node']; - - $total_votes = 0; - $highest_votes = 0; - foreach ($node->choice as $choice) { - if ($choice['chvotes'] > $highest_votes) { - $winner = $choice; - $highest_votes = $choice['chvotes']; - } - $total_votes = $total_votes + $choice['chvotes']; - } - foreach ($tokens as $name => $original) { - switch ($name) { - case 'poll-votes': - $replacements[$original] = $total_votes; - break; - - case 'poll-winner': - if (isset($winner)) { - $replacements[$original] = $sanitize ? filter_xss($winner['chtext']) : $winner['chtext']; - } - else { - $replacements[$original] = ''; - } - break; - - case 'poll-winner-votes': - if (isset($winner)) { - $replacements[$original] = $winner['chvotes']; - } - else { - $replacements[$original] = ''; - } - break; - - case 'poll-winner-percent': - if (isset($winner)) { - $percent = ($winner['chvotes'] / $total_votes) * 100; - $replacements[$original] = number_format($percent, 0); - } - else { - $replacements[$original] = ''; - } - break; - - case 'poll-duration': - $replacements[$original] = format_interval($node->runtime, 1, $langcode); - break; - } - } - } - - return $replacements; -} diff --git a/core/modules/poll/templates/poll-results.tpl.php b/core/modules/poll/templates/poll-results.tpl.php deleted file mode 100644 index 1e045fa..0000000 --- a/core/modules/poll/templates/poll-results.tpl.php +++ /dev/null @@ -1,38 +0,0 @@ - -
- -

- -
- -
-
- $votes)); ?> -
- - - -
- - - diff --git a/core/modules/poll/templates/poll-vote.tpl.php b/core/modules/poll/templates/poll-vote.tpl.php deleted file mode 100644 index f2aeb2c..0000000 --- a/core/modules/poll/templates/poll-vote.tpl.php +++ /dev/null @@ -1,31 +0,0 @@ - -
-
- - -

- - - - -
- - -
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php index d55d472..8026383 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php @@ -134,11 +134,11 @@ function testModuleEnableOrder() { $this->assertModules(array('module_test'), TRUE); state()->set('module_test.dependency', 'dependency'); // module_test creates a dependency chain: - // - forum depends on taxonomy, comment, history, and poll (via module_test) + // - forum depends on taxonomy, comment, history, and ban (via module_test) // - taxonomy depends on options - // - poll depends on php (via module_test) + // - ban depends on php (via module_test) // The correct enable order is: - $expected_order = array('comment', 'history', 'options', 'taxonomy', 'php', 'poll', 'forum'); + $expected_order = array('php', 'ban', 'comment', 'history', 'options', 'taxonomy', 'forum'); // Enable the modules through the UI, verifying that the dependency chain // is correct. @@ -146,15 +146,15 @@ function testModuleEnableOrder() { $edit['modules[Core][forum][enable]'] = 'forum'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); $this->assertModules(array('forum'), FALSE); - $this->assertText(t('You must enable the History, Taxonomy, Options, Comment, Poll, PHP Filter modules to install Forum.')); + $this->assertText(t('You must enable the History, Taxonomy, Options, Comment, Ban, PHP Filter modules to install Forum.')); $edit['modules[Core][history][enable]'] = 'history'; $edit['modules[Core][options][enable]'] = 'options'; $edit['modules[Core][taxonomy][enable]'] = 'taxonomy'; $edit['modules[Core][comment][enable]'] = 'comment'; - $edit['modules[Core][poll][enable]'] = 'poll'; + $edit['modules[Core][ban][enable]'] = 'ban'; $edit['modules[Core][php][enable]'] = 'php'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); - $this->assertModules(array('forum', 'poll', 'php', 'comment', 'history', 'taxonomy', 'options'), TRUE); + $this->assertModules(array('forum', 'ban', 'php', 'comment', 'history', 'taxonomy', 'options'), TRUE); // Check the actual order which is saved by module_test_modules_enabled(). $module_order = state()->get('system_test.module_enable_order') ?: array(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index 42924bf..d3d5e13 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -43,18 +43,18 @@ function testModuleList() { $this->assertModuleList($module_list, t('Standard profile')); // Try to install a new module. - module_enable(array('contact')); - $module_list[] = 'contact'; + module_enable(array('ban')); + $module_list[] = 'ban'; sort($module_list); $this->assertModuleList($module_list, t('After adding a module')); // Try to mess with the module weights. - module_set_weight('contact', 20); + module_set_weight('ban', 20); // Reset the module list. system_list_reset(); - // Move contact to the end of the array. - unset($module_list[array_search('contact', $module_list)]); - $module_list[] = 'contact'; + // Move ban to the end of the array. + unset($module_list[array_search('ban', $module_list)]); + $module_list[] = 'ban'; $this->assertModuleList($module_list, t('After changing weights')); // Test the fixed list feature. @@ -154,10 +154,10 @@ function testDependencyResolution() { module_enable(array('module_test'), FALSE); $this->assertTrue(module_exists('module_test'), 'Test module is enabled.'); $this->assertFalse(module_exists('forum'), 'Forum module is disabled.'); - $this->assertFalse(module_exists('poll'), 'Poll module is disabled.'); + $this->assertFalse(module_exists('ban'), 'Ban module is disabled.'); $this->assertFalse(module_exists('php'), 'PHP module is disabled.'); - // First, create a fake missing dependency. Forum depends on poll, which + // First, create a fake missing dependency. Forum depends on ban, which // depends on a made-up module, foo. Nothing should be installed. state()->set('module_test.dependency', 'missing dependency'); drupal_static_reset('system_rebuild_module_data'); @@ -165,26 +165,26 @@ function testDependencyResolution() { $this->assertFalse($result, 'module_enable() returns FALSE if dependencies are missing.'); $this->assertFalse(module_exists('forum'), 'module_enable() aborts if dependencies are missing.'); - // Now, fix the missing dependency. Forum module depends on poll, but poll + // Now, fix the missing dependency. Forum module depends on ban, but ban // depends on the PHP module. module_enable() should work. state()->set('module_test.dependency', 'dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertTrue($result, 'module_enable() returns the correct value.'); // Verify that the fake dependency chain was installed. - $this->assertTrue(module_exists('poll') && module_exists('php'), 'Dependency chain was installed by module_enable().'); + $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by module_enable().'); // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. $module_order = state()->get('system_test.module_enable_order') ?: array(); - $this->assertEqual($module_order, array('php', 'poll', 'forum'), 'Modules were enabled in the correct order by module_enable().'); + $this->assertEqual($module_order, array('php', 'ban', 'forum'), 'Modules were enabled in the correct order by module_enable().'); - // Now, disable the PHP module. Both forum and poll should be disabled as + // Now, disable the PHP module. Both forum and ban should be disabled as // well, in the correct order. module_disable(array('php')); - $this->assertTrue(!module_exists('forum') && !module_exists('poll'), 'Depedency chain was disabled by module_disable().'); + $this->assertTrue(!module_exists('forum') && !module_exists('ban'), 'Depedency chain was disabled by module_disable().'); $this->assertFalse(module_exists('php'), 'Disabling a module with unlisted dependents succeeded.'); - $this->assertEqual(variable_get('test_module_disable_order', array()), array('forum', 'poll', 'php'), 'Modules were disabled in the correct order by module_disable().'); + $this->assertEqual(variable_get('test_module_disable_order', array()), array('forum', 'ban', 'php'), 'Modules were disabled in the correct order by module_disable().'); // Disable a module that is listed as a dependency by the installation // profile. Make sure that the profile itself is not on the list of @@ -204,19 +204,19 @@ function testDependencyResolution() { // that is too destructive to perform automatically. $result = module_uninstall(array('php')); $this->assertFalse($result, 'Calling module_uninstall() on a module whose dependents are not uninstalled fails.'); - foreach (array('forum', 'poll', 'php') as $module) { + foreach (array('forum', 'ban', 'php') as $module) { $this->assertNotEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, format_string('The @module module was not uninstalled.', array('@module' => $module))); } // Now uninstall all three modules explicitly, but in the incorrect order, // and make sure that drupal_uninstal_modules() uninstalled them in the // correct sequence. - $result = module_uninstall(array('poll', 'php', 'forum')); + $result = module_uninstall(array('ban', 'php', 'forum')); $this->assertTrue($result, 'module_uninstall() returns the correct value.'); - foreach (array('forum', 'poll', 'php') as $module) { + foreach (array('forum', 'ban', 'php') as $module) { $this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, format_string('The @module module was uninstalled.', array('@module' => $module))); } - $this->assertEqual(variable_get('test_module_uninstall_order', array()), array('forum', 'poll', 'php'), 'Modules were uninstalled in the correct order by module_uninstall().'); + $this->assertEqual(variable_get('test_module_uninstall_order', array()), array('forum', 'ban', 'php'), 'Modules were uninstalled in the correct order by module_uninstall().'); // Uninstall the profile module from above, and make sure that the profile // itself is not on the list of dependent modules to be uninstalled. @@ -227,8 +227,8 @@ function testDependencyResolution() { $this->assertTrue(in_array('comment', $uninstalled_modules), 'Comment module is in the list of uninstalled modules.'); $this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.'); - // Enable forum module again, which should enable both the poll module and - // php module. But, this time do it with poll module declaring a dependency + // Enable forum module again, which should enable both the ban module and + // php module. But, this time do it with ban module declaring a dependency // on a specific version of php module in its info file. Make sure that // module_enable() still works. state()->set('module_test.dependency', 'version dependency'); @@ -236,17 +236,17 @@ function testDependencyResolution() { $result = module_enable(array('forum')); $this->assertTrue($result, 'module_enable() returns the correct value.'); // Verify that the fake dependency chain was installed. - $this->assertTrue(module_exists('poll') && module_exists('php'), 'Dependency chain was installed by module_enable().'); + $this->assertTrue(module_exists('ban') && module_exists('php'), 'Dependency chain was installed by module_enable().'); // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. $enable_order = state()->get('system_test.module_enable_order') ?: array(); $php_position = array_search('php', $enable_order); - $poll_position = array_search('poll', $enable_order); + $ban_position = array_search('ban', $enable_order); $forum_position = array_search('forum', $enable_order); - $php_before_poll = $php_position !== FALSE && $poll_position !== FALSE && $php_position < $poll_position; - $poll_before_forum = $poll_position !== FALSE && $forum_position !== FALSE && $poll_position < $forum_position; - $this->assertTrue($php_before_poll && $poll_before_forum, 'Modules were enabled in the correct order by module_enable().'); + $php_before_ban = $php_position !== FALSE && $ban_position !== FALSE && $php_position < $ban_position; + $ban_before_forum = $ban_position !== FALSE && $forum_position !== FALSE && $ban_position < $forum_position; + $this->assertTrue($php_before_ban && $ban_before_forum, 'Modules were enabled in the correct order by module_enable().'); } /** diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 7162b1b..b80d37f 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -17,31 +17,31 @@ function module_test_permission() { function module_test_system_info_alter(&$info, $file, $type) { if (state()->get('module_test.dependency') == 'missing dependency') { if ($file->name == 'forum') { - // Make forum module depend on poll. - $info['dependencies'][] = 'poll'; + // Make forum module depend on ban. + $info['dependencies'][] = 'ban'; } - elseif ($file->name == 'poll') { - // Make poll depend on a made-up module. + elseif ($file->name == 'ban') { + // Make ban depend on a made-up module. $info['dependencies'][] = 'foo'; } } elseif (state()->get('module_test.dependency') == 'dependency') { if ($file->name == 'forum') { - // Make the forum module depend on poll. - $info['dependencies'][] = 'poll'; + // Make the forum module depend on ban. + $info['dependencies'][] = 'ban'; } - elseif ($file->name == 'poll') { - // Make poll depend on php module. + elseif ($file->name == 'ban') { + // Make ban depend on php module. $info['dependencies'][] = 'php'; } } elseif (state()->get('module_test.dependency') == 'version dependency') { if ($file->name == 'forum') { - // Make the forum module depend on poll. - $info['dependencies'][] = 'poll'; + // Make the forum module depend on ban. + $info['dependencies'][] = 'ban'; } - elseif ($file->name == 'poll') { - // Make poll depend on a specific version of php module. + elseif ($file->name == 'ban') { + // Make ban depend on a specific version of php module. $info['dependencies'][] = 'php (1.x)'; } elseif ($file->name == 'php') { diff --git a/core/themes/bartik/css/style-rtl.css b/core/themes/bartik/css/style-rtl.css index cdd3f1d..55d5030 100644 --- a/core/themes/bartik/css/style-rtl.css +++ b/core/themes/bartik/css/style-rtl.css @@ -248,22 +248,6 @@ ul.action-links li a { float: right; } -/* ---------- Poll ----------- */ - -.poll .vote-form { - text-align: right; -} -.poll .total { - text-align: left; -} -.poll .choice-title { - clear: left; -} -.poll .percent { - float: left; - text-align: left; -} - /* ---------- Color Form ----------- */ .color-form #palette { diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index a748fd4..c50301a 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -1507,54 +1507,6 @@ div.admin-panel .description { width: auto; } -/* ---------- Poll ----------- */ - -.node .poll { - margin: 2em 0; -} -.node .poll #edit-choice { - margin: 0 0 1.5em; -} -.poll .vote-form { - text-align: left; /* LTR */ - margin: 0; -} -.poll .percent { - font-size: 0.857em; - font-style: italic; - margin-bottom: 3em; - margin-top: -3.2em; - float: right; /* LTR */ - text-align: right; /* LTR */ -} -.poll .choice-title { - clear: right; /* LTR */ -} -.poll .total { - font-size: 0.929em; - font-style: italic; - text-align: right; /* LTR */ - clear: both; -} -.node .poll { - margin: 1.8em 0 0; -} -.node .poll .text { - margin-right: 6.75em; -} -.node .poll #edit-choice { - margin: 0 0 1.2em; -} -.poll .bar .foreground { - background-color: #666; -} -#footer-wrapper .poll .bar { - background-color: #666; -} -#footer-wrapper .poll .bar .foreground { - background-color: #ddd; -} - /* ---------- book ----------- */ .book-navigation .menu { border-top: 1px solid #d6d6d6;