Skip to content
Snippets Groups Projects
Commit 7abbba0b authored by Jennifer Hodgdon's avatar Jennifer Hodgdon
Browse files

Issue #1797514 by Gaelan, Lars Toomre: Remove t() from test assertions in simpletest module

parent 000def44
No related branches found
No related tags found
No related merge requests found
......@@ -29,18 +29,18 @@ function testGetAbsoluteUrl() {
$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.');
}
/**
......
......@@ -31,6 +31,6 @@ public static function getInfo() {
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.');
}
}
......@@ -38,19 +38,19 @@ function testMailSend() {
// 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.
......@@ -67,20 +67,20 @@ function testMailSend() {
// 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');
}
}
......@@ -58,7 +58,7 @@ function testInternalBrowser() {
if (!$this->inCURL()) {
// Retrieve the test page and check its title and headers.
$this->drupalGet('test-page');
$this->assertTrue($this->drupalGetHeader('Date'), t('An HTTP header was received.'));
$this->assertTrue($this->drupalGetHeader('Date'), 'An HTTP header was received.');
$this->assertTitle(t('Test page | @site-name', array(
'@site-name' => config('system.site')->get('name'),
)));
......@@ -74,12 +74,12 @@ function testInternalBrowser() {
$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();
......@@ -92,7 +92,7 @@ function testInternalBrowser() {
'query' => array('destination' => 'user/logout'),
));
$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.');
}
}
......@@ -106,30 +106,30 @@ function testUserAgentValidation() {
$HTTP_path = $system_path .'/tests/http.php?q=node';
$https_path = $system_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.');
}
}
......@@ -165,7 +165,7 @@ function testWebTestRunner() {
// 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.');
}
}
......@@ -228,7 +228,7 @@ function confirmStubTestResults() {
$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.');
}
/**
......@@ -267,7 +267,7 @@ function assertAssertion($message, $type, $status, $file, $function) {
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)));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment