diff --git a/modules/poll/poll.test b/modules/poll/poll.test index 9982222c82b4b2bc1fe88479b9c51e2ce706f6fc..35eea2237268166007d850b69656016ed9c37189 100644 --- a/modules/poll/poll.test +++ b/modules/poll/poll.test @@ -64,7 +64,7 @@ class PollTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); $this->assertText(t('@type @title has been created.', array('@type' => node_type_get_name('poll'), '@title' => $title)), 'Poll has been created.'); - $this->assertTrue($node->nid, t('Poll has been found in the database.')); + $this->assertTrue($node->nid, 'Poll has been found in the database.'); return isset($node->nid) ? $node->nid : FALSE; } @@ -137,7 +137,7 @@ class PollTestCase extends DrupalWebTestCase { // 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, t('Found choice @id with weight @weight.', array( + $this->assertFieldByName('choice[chid:' . $id . '][weight]', $weight, format_string('Found choice @id with weight @weight.', array( '@id' => $id, '@weight' => $weight, ))); @@ -167,7 +167,7 @@ class PollTestCase extends DrupalWebTestCase { $expected_order = $expected; foreach ($elements as $element) { $next_label = array_shift($expected_order); - $this->assertEqual((string) $element, $next_label, t('Found choice @label in preview.', array( + $this->assertEqual((string) $element, $next_label, format_string('Found choice @label in preview.', array( '@label' => $next_label, ))); } @@ -232,7 +232,7 @@ class PollCreateTestCase extends PollTestCase { $this->assertEqual(end($option), $new_option, 'Last item is equal to new option.'); $votes = $this->xpath('//div[@id="node-1"]//div[@class="poll"]//div[@class="percent"]'); - $this->assertTrue(strpos(end($votes), $vote_count) > 0, t("Votes saved.")); + $this->assertTrue(strpos(end($votes), $vote_count) > 0, "Votes saved."); } function testPollClose() { @@ -254,7 +254,7 @@ class PollCreateTestCase extends PollTestCase { // Verify 'Vote' button no longer appears. $this->drupalGet('node/' . $poll_nid); $elements = $this->xpath('//input[@id="edit-vote"]'); - $this->assertTrue(empty($elements), t("Vote button doesn't appear.")); + $this->assertTrue(empty($elements), "Vote button doesn't appear."); // Verify status on 'poll' page is 'closed'. $this->drupalGet('poll'); @@ -272,7 +272,7 @@ class PollCreateTestCase extends PollTestCase { $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]), t("'Cancel your vote' button appears.")); + $this->assertTrue(isset($elements[0]), "'Cancel your vote' button appears."); // Edit the poll node and close the poll. $this->drupalLogout(); @@ -283,7 +283,7 @@ class PollCreateTestCase extends PollTestCase { // 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), t("'Cancel your vote' button no longer appears.")); + $this->assertTrue(empty($elements), "'Cancel your vote' button no longer appears."); } } @@ -323,7 +323,7 @@ class PollVoteTestCase extends PollTestCase { $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]), t("'Cancel your vote' button appears.")); + $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.'); @@ -359,7 +359,7 @@ class PollVoteTestCase extends PollTestCase { $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), t("'Cancel your vote' button does not appear.")); + $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); } } @@ -383,13 +383,13 @@ class PollBlockTestCase extends PollTestCase { 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.'), t('Block configuration set.')); + $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.'), t('Block successfully move to footer region.')); + $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(); @@ -465,9 +465,9 @@ class PollJSAddChoice extends DrupalWebTestCase { $commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('More choices'))); $this->content = $commands[1]['data']; - $this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], t('Field !i found', array('!i' => 0))); - $this->assertFieldByName('choice[chid:1][chtext]', $edit['choice[new:1][chtext]'], t('Field !i found', array('!i' => 1))); - $this->assertFieldByName('choice[new:0][chtext]', '', t('Field !i found', array('!i' => 2))); + $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))); } } @@ -524,49 +524,49 @@ class PollVoteCheckHostname extends PollTestCase { // User1 vote on Poll. $this->drupalPost('node/' . $this->poll_nid, $edit, t('Vote')); - $this->assertText(t('Your vote was recorded.'), t('%user vote was recorded.', array('%user' => $this->web_user1->name))); - $this->assertText(t('Total votes: @votes', array('@votes' => 1)), t('Vote count updated correctly.')); + $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), t("%user is not able to vote again.", array('%user' => $this->web_user1->name))); + $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), t("'Cancel your vote' button appears.")); + $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', t('Page was cacheable but was not in the cache.')); + $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', t('Page was cached.')); + $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.'), t('Anonymous vote was recorded.')); - $this->assertText(t('Total votes: @votes', array('@votes' => 2)), t('Vote count updated correctly.')); + $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), t("'Cancel your vote' button appears.")); + $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'), t('Page was not cacheable.')); + $this->assertFalse($this->drupalGetHeader('x-drupal-cache'), 'Page was not cacheable.'); $elements = $this->xpath('//input[@value="Vote"]'); - $this->assertTrue(empty($elements), t("Anonymous is not able to vote again.")); + $this->assertTrue(empty($elements), "Anonymous is not able to vote again."); $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(!empty($elements), t("'Cancel your vote' button appears.")); + $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.'), t('%user vote was recorded.', array('%user' => $this->web_user2->name))); + $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), t("'Cancel your vote' button does not appear.")); + $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); // Logout User2. $this->drupalLogout(); @@ -582,22 +582,22 @@ class PollVoteCheckHostname extends PollTestCase { // 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', t('Page was cacheable but was not in the cache.')); + $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.'), t('%user vote was recorded.', array('%user' => $this->web_user2->name))); + $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), t("'Cancel your vote' button appears.")); + $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', t('Page was cacheable but was not in the cache.')); + $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), t('Anonymous is not able to vote again.')); + $this->assertTrue(empty($elements), 'Anonymous is not able to vote again.'); $elements = $this->xpath('//input[@value="Cancel your vote"]'); - $this->assertTrue(empty($elements), t("'Cancel your vote' button does not appear.")); + $this->assertTrue(empty($elements), "'Cancel your vote' button does not appear."); // Login User1. $this->drupalLogin($this->web_user1); @@ -605,9 +605,9 @@ class PollVoteCheckHostname extends PollTestCase { // 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), t("%user is not able to vote again.", array('%user' => $this->web_user1->name))); + $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), t("'Cancel your vote' button appears.")); + $this->assertTrue(!empty($elements), "'Cancel your vote' button appears."); } } @@ -683,11 +683,11 @@ class PollTokenReplaceTestCase extends PollTestCase { $tests['[node:poll-duration]'] = format_interval($poll->runtime, 1, $language->language); // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.')); + $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('language' => $language)); - $this->assertEqual($output, $expected, t('Sanitized poll token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Sanitized poll token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -695,7 +695,7 @@ class PollTokenReplaceTestCase extends PollTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $poll), array('language' => $language, 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, t('Unsanitized poll token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Unsanitized poll token %token replaced.', array('%token' => $input))); } } } @@ -718,33 +718,33 @@ class PollExpirationTestCase extends PollTestCase { $title = $this->randomName(); $choices = $this->_generateChoices(2); $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->assertTrue($poll_nid, t('Poll for auto-expire test created.')); + $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', t('Poll expiration setting found.')); + $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, t('Poll expiration set to unlimited.')); + $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)), t('Poll expiration settings saved.')); + $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, t('Poll expiration set to unlimited.')); + $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']), t('Poll is still active.')); + $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, @@ -759,7 +759,7 @@ class PollExpirationTestCase extends PollTestCase { 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']), t('Poll has expired.')); + $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), 'Poll has expired.'); } } @@ -781,7 +781,7 @@ class PollDeleteChoiceTestCase extends PollTestCase { $title = $this->randomName(); $choices = array('First choice', 'Second choice', 'Third choice'); $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->assertTrue($poll_nid, t('Poll for choice deletion logic test created.')); + $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"); @@ -793,9 +793,9 @@ class PollDeleteChoiceTestCase extends PollTestCase { $this->clickLink($title); // Check the first poll choice is deleted, while the others remain. - $this->assertNoText('First choice', t('First choice removed.')); - $this->assertText('Second choice', t('Second choice remains.')); - $this->assertText('Third choice', t('Third choice remains.')); + $this->assertNoText('First choice', 'First choice removed.'); + $this->assertText('Second choice', 'Second choice remains.'); + $this->assertText('Third choice', 'Third choice remains.'); } } @@ -828,7 +828,7 @@ class PollTranslateTestCase extends PollTestCase { $title = $this->randomName(); $choices = array($this->randomName(), $this->randomName()); $poll_nid = $this->pollCreate($title, $choices, FALSE); - $this->assertTrue($poll_nid, t('Poll for translation logic test created.')); + $this->assertTrue($poll_nid, 'Poll for translation logic test created.'); $this->drupalLogout(); $this->drupalLogin($admin_user); @@ -838,14 +838,14 @@ class PollTranslateTestCase extends PollTestCase { $edit = array(); $edit['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')), t('Language Dutch has been created.')); + $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(); $edit['language_content_type'] = 2; $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')), t('Poll content type has been updated.')); + $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"); @@ -866,7 +866,7 @@ class PollTranslateTestCase extends PollTestCase { $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'], t('Found choice with text @text', array('@text' => $dutch_poll->choice[1]['chtext']))); - $this->assertFieldByName('choice[chid:2][chtext]', $dutch_poll->choice[2]['chtext'], t('Found choice with text @text', array('@text' => $dutch_poll->choice[2]['chtext']))); + $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']))); } }