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 5b0435b..64fa105 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/Plugin/block/block/PollRecentBlock.php b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php deleted file mode 100644 index 242c32f..0000000 --- a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php +++ /dev/null @@ -1,81 +0,0 @@ - array( - 'administrative' => TRUE, - ), - ); - } - - /** - * Overrides \Drupal\block\BlockBase::access(). - */ - public function blockAccess() { - 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) { - $this->record = $record->nid; - return TRUE; - } - } - return FALSE; - } - - /** - * Implements \Drupal\block\BlockBase::build(). - */ - public function build() { - $poll = node_load($this->record); - if ($poll->nid) { - $poll = poll_block_latest_poll_view($poll); - return array( - $poll->content - ); - } - return array(); - } - -} 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 6a86d21..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 - $this->adminUser = $this->drupalCreateUser(array('administer blocks')); - $this->drupalLogin($this->adminUser); - } - - /** - * Tests creating, viewing, voting on recent poll block. - */ - function testRecentBlock() { - // Enable the recent poll block. - $this->drupalPlaceBlock('poll_recent_block'); - - // 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 8cc01e7..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_show]' => TRUE, '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 f6b5386..0000000 --- a/core/modules/poll/poll.info +++ /dev/null @@ -1,6 +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 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 85d29b4..0000000 --- a/core/modules/poll/poll.module +++ /dev/null @@ -1,1013 +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 .= '