Commit e01afb83 authored by jhodgdon's avatar jhodgdon

Issue #1797514 by disasm, dicam, Gaelan, Lars Toomre: Remove t() from test...

Issue #1797514 by disasm, dicam, Gaelan, Lars Toomre: Remove t() from test assert messages in simpletest module
parent 1d50605e
......@@ -45,9 +45,9 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
global $conf;
if (!$this->inCURL()) {
$this->drupalGet('node');
$this->assertTrue($this->drupalGetHeader('Date'), t('An HTTP header was received.'));
$this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.'));
$this->assertNoTitle('Foo', t('Site title does not match.'));
$this->assertTrue($this->drupalGetHeader('Date'), 'An HTTP header was received.');
$this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), 'Site title matches.');
$this->assertNoTitle('Foo', 'Site title does not match.');
// Make sure that we are locked out of the installer when prefixing
// using the user-agent header. This is an important security check.
global $base_url;
......@@ -58,12 +58,12 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
$headers = $this->drupalGetHeaders(TRUE);
$this->assertEqual(count($headers), 2, t('There was one intermediate request.'));
$this->assertTrue(strpos($headers[0][':status'], '302') !== FALSE, t('Intermediate response code was 302.'));
$this->assertFalse(empty($headers[0]['location']), t('Intermediate request contained a Location header.'));
$this->assertEqual($this->getUrl(), $headers[0]['location'], t('HTTP redirect was followed'));
$this->assertFalse($this->drupalGetHeader('Location'), t('Headers from intermediate request were reset.'));
$this->assertResponse(200, t('Response code from intermediate request was reset.'));
$this->assertEqual(count($headers), 2, 'There was one intermediate request.');
$this->assertTrue(strpos($headers[0][':status'], '302') !== FALSE, 'Intermediate response code was 302.');
$this->assertFalse(empty($headers[0]['location']), 'Intermediate request contained a Location header.');
$this->assertEqual($this->getUrl(), $headers[0]['location'], 'HTTP redirect was followed');
$this->assertFalse($this->drupalGetHeader('Location'), 'Headers from intermediate request were reset.');
$this->assertResponse(200, 'Response code from intermediate request was reset.');
// Test the maximum redirection option.
$this->drupalLogout();
......@@ -74,7 +74,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
variable_set('simpletest_maximum_redirects', 1);
$this->drupalPost('user?destination=user/logout', $edit, t('Log in'));
$headers = $this->drupalGetHeaders(TRUE);
$this->assertEqual(count($headers), 2, t('Simpletest stopped following redirects after the first one.'));
$this->assertEqual(count($headers), 2, 'Simpletest stopped following redirects after the first one.');
}
}
......@@ -88,30 +88,30 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
$HTTP_path = $simpletest_path .'/tests/http.php?q=node';
$https_path = $simpletest_path .'/tests/https.php?q=node';
// Generate a valid simpletest User-Agent to pass validation.
$this->assertTrue(preg_match('/simpletest\d+/', $this->databasePrefix, $matches), t('Database prefix contains simpletest prefix.'));
$this->assertTrue(preg_match('/simpletest\d+/', $this->databasePrefix, $matches), 'Database prefix contains simpletest prefix.');
$test_ua = drupal_generate_test_ua($matches[0]);
$this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua);
// Test pages only available for testing.
$this->drupalGet($HTTP_path);
$this->assertResponse(200, t('Requesting http.php with a legitimate simpletest User-Agent returns OK.'));
$this->assertResponse(200, 'Requesting http.php with a legitimate simpletest User-Agent returns OK.');
$this->drupalGet($https_path);
$this->assertResponse(200, t('Requesting https.php with a legitimate simpletest User-Agent returns OK.'));
$this->assertResponse(200, 'Requesting https.php with a legitimate simpletest User-Agent returns OK.');
// Now slightly modify the HMAC on the header, which should not validate.
$this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua . 'X');
$this->drupalGet($HTTP_path);
$this->assertResponse(403, t('Requesting http.php with a bad simpletest User-Agent fails.'));
$this->assertResponse(403, 'Requesting http.php with a bad simpletest User-Agent fails.');
$this->drupalGet($https_path);
$this->assertResponse(403, t('Requesting https.php with a bad simpletest User-Agent fails.'));
$this->assertResponse(403, 'Requesting https.php with a bad simpletest User-Agent fails.');
// Use a real User-Agent and verify that the special files http.php and
// https.php can't be accessed.
$this->additionalCurlOptions = array(CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
$this->drupalGet($HTTP_path);
$this->assertResponse(403, t('Requesting http.php with a normal User-Agent fails.'));
$this->assertResponse(403, 'Requesting http.php with a normal User-Agent fails.');
$this->drupalGet($https_path);
$this->assertResponse(403, t('Requesting https.php with a normal User-Agent fails.'));
$this->assertResponse(403, 'Requesting https.php with a normal User-Agent fails.');
}
}
......@@ -147,7 +147,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
// Regression test for #290316.
// Check that test_id is incrementing.
$this->assertTrue($this->test_ids[0] != $this->test_ids[1], t('Test ID is incrementing.'));
$this->assertTrue($this->test_ids[0] != $this->test_ids[1], 'Test ID is incrementing.');
}
}
......@@ -210,7 +210,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
$this->assertEqual('6 passes, 5 fails, 2 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct');
$this->test_ids[] = $test_id = $this->getTestIdFromResults();
$this->assertTrue($test_id, t('Found test ID in results.'));
$this->assertTrue($test_id, 'Found test ID in results.');
}
/**
......@@ -249,7 +249,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
break;
}
}
return $this->assertTrue($found, t('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', array('@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function)));
return $this->assertTrue($found, format_string('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', array('@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function)));
}
/**
......@@ -345,18 +345,18 @@ class SimpleTestBrowserTestCase extends DrupalWebTestCase {
$this->drupalGet($url);
$absolute = url($url, array('absolute' => TRUE));
$this->assertEqual($absolute, $this->url, t('Passed and requested URL are equal.'));
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), t('Requested and returned absolute URL are equal.'));
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
$this->drupalPost(NULL, array(), t('Log in'));
$this->assertEqual($absolute, $this->url, t('Passed and requested URL are equal.'));
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), t('Requested and returned absolute URL are equal.'));
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
$this->clickLink('Create new account');
$url = 'user/register';
$absolute = url($url, array('absolute' => TRUE));
$this->assertEqual($absolute, $this->url, t('Passed and requested URL are equal.'));
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), t('Requested and returned absolute URL are equal.'));
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
}
/**
......@@ -411,19 +411,19 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
// Before we send the e-mail, drupalGetMails should return an empty array.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 0, t('The captured e-mails queue is empty.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 0, 'The captured e-mails queue is empty.', 'E-mail');
// Send the e-mail.
$response = drupal_mail_system('simpletest', 'drupal_mail_test')->mail($message);
// Ensure that there is one e-mail in the captured e-mails array.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 1, t('One e-mail was captured.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 1, 'One e-mail was captured.', 'E-mail');
// Assert that the e-mail was sent by iterating over the message properties
// and ensuring that they are captured intact.
foreach ($message as $field => $value) {
$this->assertMail($field, $value, t('The e-mail was sent and the value for property @field is intact.', array('@field' => $field)), t('E-mail'));
$this->assertMail($field, $value, format_string('The e-mail was sent and the value for property @field is intact.', array('@field' => $field)), 'E-mail');
}
// Send additional e-mails so more than one e-mail is captured.
......@@ -440,21 +440,21 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
// There should now be 6 e-mails captured.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 6, t('All e-mails were captured.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 6, 'All e-mails were captured.', 'E-mail');
// Test different ways of getting filtered e-mails via drupalGetMails().
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test'));
$this->assertEqual(count($captured_emails), 1, t('Only one e-mail is returned when filtering by id.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 1, 'Only one e-mail is returned when filtering by id.', 'E-mail');
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject));
$this->assertEqual(count($captured_emails), 1, t('Only one e-mail is returned when filtering by id and subject.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 1, 'Only one e-mail is returned when filtering by id and subject.', 'E-mail');
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
$this->assertEqual(count($captured_emails), 0, t('No e-mails are returned when querying with an unused from address.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 0, 'No e-mails are returned when querying with an unused from address.', 'E-mail');
// Send the last e-mail again, so we can confirm that the drupalGetMails-filter
// correctly returns all e-mails with a given property/value.
drupal_mail_system('drupal_mail_test', $index)->mail($message);
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
$this->assertEqual(count($captured_emails), 2, t('All e-mails with the same id are returned when filtering by id.'), t('E-mail'));
$this->assertEqual(count($captured_emails), 2, 'All e-mails with the same id are returned when filtering by id.', 'E-mail');
}
}
......@@ -476,7 +476,7 @@ class SimpleTestFolderTestCase extends DrupalWebTestCase {
function testFolderSetup() {
$directory = file_default_scheme() . '://styles';
$this->assertTrue(file_prepare_directory($directory, FALSE), "Directory created.");
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
}
}
......
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