Commit 55aebf4e authored by jhodgdon's avatar jhodgdon

Issue #1797376 by xjm: Remove t() from test assertions in poll module

parent 22f70763
......@@ -35,13 +35,13 @@ function setUp() {
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();
......
......@@ -54,7 +54,7 @@ function testPollCreate() {
$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, t("Votes saved."));
$this->assertTrue(strpos(end($votes), $vote_count) > 0, "Votes saved.");
}
function testPollClose() {
......@@ -76,7 +76,7 @@ function testPollClose() {
// 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');
......@@ -94,7 +94,7 @@ function testPollClose() {
$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();
......@@ -105,6 +105,6 @@ function testPollClose() {
// 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.");
}
}
......@@ -21,7 +21,7 @@ function testChoiceRemoval() {
$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");
......@@ -33,8 +33,8 @@ function testChoiceRemoval() {
$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.');
}
}
......@@ -21,33 +21,33 @@ function testAutoExpire() {
$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,
......@@ -62,6 +62,6 @@ function testAutoExpire() {
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.');
}
}
......@@ -47,8 +47,8 @@ function testAddChoice() {
$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]'], 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)));
}
}
......@@ -75,7 +75,7 @@ function pollCreate($title, $choices, $preview = TRUE) {
$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, 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;
}
......@@ -148,7 +148,7 @@ function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) {
// 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,
)));
......@@ -178,7 +178,7 @@ function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) {
$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,
)));
}
......
......@@ -75,11 +75,11 @@ function testPollTokenReplacement() {
$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)), 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('langcode' => $language_interface->langcode));
$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.
......@@ -87,7 +87,7 @@ function testPollTokenReplacement() {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode, '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)));
}
}
}
......@@ -40,7 +40,7 @@ function testPollTranslate() {
$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);
......@@ -50,13 +50,13 @@ function testPollTranslate() {
$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')), 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('node_type_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')), 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");
......@@ -77,7 +77,7 @@ function testPollTranslate() {
$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'])));
}
}
......@@ -62,49 +62,49 @@ function testHostnamePollVote() {
// 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();
......@@ -120,22 +120,22 @@ function testHostnamePollVote() {
// 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);
......@@ -143,8 +143,8 @@ function testHostnamePollVote() {
// 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.");
}
}
......@@ -39,7 +39,7 @@ function testPollVote() {
$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.');
......@@ -75,6 +75,6 @@ function testPollVote() {
$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.");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment