Issue #1797360 by xjm: Remove t() from test assertions in language module

8.0.x
Jennifer Hodgdon 2012-10-01 15:08:28 -07:00
parent d57f04d3f8
commit 1518a9434e
8 changed files with 58 additions and 58 deletions

View File

@ -156,7 +156,7 @@ class LanguageBrowserDetectionUnitTest extends WebTestBase {
foreach ($test_cases as $accept_language => $expected_result) {
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $accept_language;
$result = language_from_browser($languages);
$this->assertIdentical($result, $expected_result, t("Language selection '@accept-language' selects '@result', result = '@actual'", array('@accept-language' => $accept_language, '@result' => $expected_result, '@actual' => isset($result) ? $result : 'none')));
$this->assertIdentical($result, $expected_result, format_string("Language selection '@accept-language' selects '@result', result = '@actual'", array('@accept-language' => $accept_language, '@result' => $expected_result, '@actual' => isset($result) ? $result : 'none')));
}
}

View File

@ -51,7 +51,7 @@ class LanguageDependencyInjectionTest extends WebTestBase {
$expected = language_default();
$result = language(LANGUAGE_TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, t('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
$this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
}
}
@ -81,7 +81,7 @@ class LanguageDependencyInjectionTest extends WebTestBase {
$expected = new Language($new_language_default);
$result = language(LANGUAGE_TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, t('The dependency injected language object %prop property equals the default language object %prop property.', array('%prop' => $property)));
$this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the default language object %prop property.', array('%prop' => $property)));
}
// Delete the language_default variable we previously set.

View File

@ -45,8 +45,8 @@ class LanguageListTest extends WebTestBase {
'predefined_langcode' => 'fr',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', t('Language added successfully.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText('French', 'Language added successfully.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Add custom language.
$langcode = 'xx';
@ -58,38 +58,38 @@ class LanguageListTest extends WebTestBase {
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertRaw('"edit-site-default-' . $langcode .'"', t('Language code found.'));
$this->assertText(t($name), t('Test language added.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertRaw('"edit-site-default-' . $langcode .'"', 'Language code found.');
$this->assertText(t($name), 'Test language added.');
// Check if we can change the default language.
$path = 'admin/config/regional/language';
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-en', t('English is the default language.'));
$this->assertFieldChecked('edit-site-default-en', 'English is the default language.');
// Change the default language.
$edit = array(
'site_default' => $langcode,
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertNoFieldChecked('edit-site-default-en', 'Default language updated.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Ensure we can't delete the default language.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText(t('The default language cannot be deleted.'), t('Failed to delete the default language.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertText(t('The default language cannot be deleted.'), 'Failed to delete the default language.');
// Ensure 'edit' link works.
$this->clickLink(t('edit'));
$this->assertTitle(t('Edit language | Drupal'), t('Page title is "Edit language".'));
$this->assertTitle(t('Edit language | Drupal'), 'Page title is "Edit language".');
// Edit a language.
$name = $this->randomName(16);
$edit = array(
'name' => $name,
);
$this->drupalPost('admin/config/regional/language/edit/' . $langcode, $edit, t('Save language'));
$this->assertRaw($name, t('The language has been updated.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertRaw($name, 'The language has been updated.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Change back the default language.
$edit = array(
@ -99,27 +99,27 @@ class LanguageListTest extends WebTestBase {
// Ensure 'delete' link works.
$this->drupalGet('admin/config/regional/language');
$this->clickLink(t('delete'));
$this->assertText(t('Are you sure you want to delete the language'), t('"delete" link is correct.'));
$this->assertText(t('Are you sure you want to delete the language'), '"delete" link is correct.');
// Delete a language.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
// First test the 'cancel' link.
$this->clickLink(t('Cancel'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertRaw($name, t('The language was not deleted.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertRaw($name, 'The language was not deleted.');
// Delete the language for real. This a confirm form, we do not need any
// fields changed.
$this->drupalPost('admin/config/regional/language/delete/' . $langcode, array(), t('Delete'));
// We need raw here because %language and %langcode will add HTML.
$t_args = array('%language' => $name, '%langcode' => $langcode);
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), t('The test language has been removed.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
$this->assertResponse(404, t('Language no longer found.'));
$this->assertResponse(404, 'Language no longer found.');
// Make sure the "language_count" variable has been updated correctly.
drupal_static_reset('language_list');
$languages = language_list();
$this->assertEqual(variable_get('language_count', 1), count($languages), t('Language count is correct.'));
$this->assertEqual(variable_get('language_count', 1), count($languages), 'Language count is correct.');
// Delete French.
$this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete'));
// Get the count of languages.
@ -127,13 +127,13 @@ class LanguageListTest extends WebTestBase {
$languages = language_list();
// We need raw here because %language and %langcode will add HTML.
$t_args = array('%language' => 'French', '%langcode' => 'fr');
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), t('Disabled language has been removed.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'Disabled language has been removed.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/fr');
$this->assertResponse(404, t('Language no longer found.'));
$this->assertResponse(404, 'Language no longer found.');
// Make sure the "language_count" variable has not changed.
$this->assertEqual(variable_get('language_count', 1), count($languages), t('Language count is correct.'));
$this->assertEqual(variable_get('language_count', 1), count($languages), 'Language count is correct.');
// Ensure we can delete the English language. Right now English is the only
// language so we must add a new language and make it the default before
@ -147,25 +147,25 @@ class LanguageListTest extends WebTestBase {
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText($name, t('Name found.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertText($name, 'Name found.');
// Check if we can change the default language.
$path = 'admin/config/regional/language';
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-en', t('English is the default language.'));
$this->assertFieldChecked('edit-site-default-en', 'English is the default language.');
// Change the default language.
$edit = array(
'site_default' => $langcode,
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertNoFieldChecked('edit-site-default-en', 'Default language updated.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
$this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));
// We need raw here because %language and %langcode will add HTML.
$t_args = array('%language' => 'English', '%langcode' => 'en');
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), t('The English language has been removed.'));
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The English language has been removed.');
}
/**
@ -182,12 +182,12 @@ class LanguageListTest extends WebTestBase {
$expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en');
$locked_languages = language_list(LANGUAGE_LOCKED);
$this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), t('Locked languages loaded correctly.'));
$this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.');
$all_languages = language_list(LANGUAGE_ALL);
$this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), t('All languages loaded correctly.'));
$this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.');
$conf_languages = language_list();
$this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), array(), t('Configurable languages loaded correctly.'));
$this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), array(), 'Configurable languages loaded correctly.');
}
}

View File

@ -56,7 +56,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
$this->languageNegotiationUpdate();
$type = LANGUAGE_TYPE_CONTENT;
$language_types = variable_get('language_types', language_types_get_default());
$this->assertTrue($language_types[$type], t('Content language type is configurable.'));
$this->assertTrue($language_types[$type], 'Content language type is configurable.');
// Enable some core and custom language negotiation methods. The test
// language type is supposed to be configurable.
@ -76,18 +76,18 @@ class LanguageNegotiationInfoTest extends WebTestBase {
variable_set('language_test_language_negotiation_info_alter', TRUE);
$this->languageNegotiationUpdate();
$negotiation = variable_get("language_negotiation_$type", array());
$this->assertFalse(isset($negotiation[$interface_method_id]), t('Interface language negotiation method removed from the stored settings.'));
$this->assertNoFieldByXPath("//input[@name=\"$form_field\"]", NULL, t('Interface language negotiation method unavailable.'));
$this->assertFalse(isset($negotiation[$interface_method_id]), 'Interface language negotiation method removed from the stored settings.');
$this->assertNoFieldByXPath("//input[@name=\"$form_field\"]", NULL, 'Interface language negotiation method unavailable.');
// Check that type-specific language negotiation methods can be assigned
// only to the corresponding language types.
foreach (language_types_get_configurable() as $type) {
$form_field = $type . '[enabled][test_language_negotiation_method_ts]';
if ($type == $test_type) {
$this->assertFieldByXPath("//input[@name=\"$form_field\"]", NULL, t('Type-specific test language negotiation method available for %type.', array('%type' => $type)));
$this->assertFieldByXPath("//input[@name=\"$form_field\"]", NULL, format_string('Type-specific test language negotiation method available for %type.', array('%type' => $type)));
}
else {
$this->assertNoFieldByXPath("//input[@name=\"$form_field\"]", NULL, t('Type-specific test language negotiation method unavailable for %type.', array('%type' => $type)));
$this->assertNoFieldByXPath("//input[@name=\"$form_field\"]", NULL, format_string('Type-specific test language negotiation method unavailable for %type.', array('%type' => $type)));
}
}
@ -97,7 +97,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
foreach (language_types_get_all() as $type) {
$langcode = $last[$type];
$value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
$this->assertEqual($langcode, $value, t('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode)));
$this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode)));
}
// Disable language_test and check that everything is set back to the
@ -106,7 +106,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
// Check that only the core language types are available.
foreach (language_types_get_all() as $type) {
$this->assertTrue(strpos($type, 'test') === FALSE, t('The %type language is still available', array('%type' => $type)));
$this->assertTrue(strpos($type, 'test') === FALSE, format_string('The %type language is still available', array('%type' => $type)));
}
// Check that fixed language types are properly configured, even those
@ -116,11 +116,11 @@ class LanguageNegotiationInfoTest extends WebTestBase {
// Check that unavailable language negotiation methods are not present in
// the negotiation settings.
$negotiation = variable_get("language_negotiation_$type", array());
$this->assertFalse(isset($negotiation[$test_method_id]), t('The disabled test language negotiation method is not part of the content language negotiation settings.'));
$this->assertFalse(isset($negotiation[$test_method_id]), 'The disabled test language negotiation method is not part of the content language negotiation settings.');
// Check that configuration page presents the correct options and settings.
$this->assertNoRaw(t('Test language detection'), t('No test language type configuration available.'));
$this->assertNoRaw(t('This is a test language negotiation method'), t('No test language negotiation method available.'));
$this->assertNoRaw(t('Test language detection'), 'No test language type configuration available.');
$this->assertNoRaw(t('This is a test language negotiation method'), 'No test language negotiation method available.');
}
/**
@ -165,7 +165,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
list(, $info_id) = each($info['fixed']);
$equal = $info_id == $id;
}
$this->assertTrue($equal, t('language negotiation for %type is properly set up', array('%type' => $type)));
$this->assertTrue($equal, format_string('language negotiation for %type is properly set up', array('%type' => $type)));
}
}
}

View File

@ -49,8 +49,8 @@ class LanguagePathMonolingualTest extends WebTestBase {
$this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));
// Verify that French is the only language.
$this->assertFalse(language_multilingual(), t('Site is mono-lingual'));
$this->assertEqual(language_default()->langcode, 'fr', t('French is the default language'));
$this->assertFalse(language_multilingual(), 'Site is mono-lingual');
$this->assertEqual(language_default()->langcode, 'fr', 'French is the default language');
// Set language detection to URL.
$edit = array('language_interface[enabled][language-url]' => TRUE);

View File

@ -60,7 +60,7 @@ class LanguageSwitchingTest extends WebTestBase {
// Assert that the language switching block is displayed on the frontpage.
$this->drupalGet('');
$this->assertText(t('Languages'), t('Language switcher block found.'));
$this->assertText(t('Languages'), 'Language switcher block found.');
// Assert that only the current language is marked as active.
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-language-' . str_replace('_', '-', $language_type)));
@ -89,7 +89,7 @@ class LanguageSwitchingTest extends WebTestBase {
$anchors['inactive'][] = $langcode;
}
}
$this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language list item is marked as active on the language switcher block.'));
$this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language anchor is marked as active on the language switcher block.'));
$this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.');
$this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.');
}
}

View File

@ -391,11 +391,11 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
// language.
$args = array(':url' => base_path() . $GLOBALS['script_path'] . $langcode_browser_fallback);
$fields = $this->xpath('//div[@id="block-language-language-interface"]//a[@class="language-link active" and starts-with(@href, :url)]', $args);
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, t('The browser language is the URL active language'));
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, 'The browser language is the URL active language');
// Check that URLs are rewritten using the given browser language.
$fields = $this->xpath('//p[@id="site-name"]/strong/a[@rel="home" and @href=:url]', $args);
$this->assertTrue($fields[0] == 'Drupal', t('URLs are rewritten using the browser language.'));
$this->assertTrue($fields[0] == 'Drupal', 'URLs are rewritten using the browser language.');
}
/**
@ -434,13 +434,13 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$italian_url = url('admin', array('language' => $languages['it'], 'script' => ''));
$url_scheme = ($is_https) ? 'https://' : 'http://';
$correct_link = $url_scheme . $link;
$this->assertTrue($italian_url == $correct_link, t('The url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url)));
$this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url)));
// Test HTTPS via options.
variable_set('https', TRUE);
$italian_url = url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => ''));
$correct_link = 'https://' . $link;
$this->assertTrue($italian_url == $correct_link, t('The url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
$this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
variable_set('https', FALSE);
// Test HTTPS via current URL scheme.
@ -448,7 +448,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$is_https = TRUE;
$italian_url = url('admin', array('language' => $languages['it'], 'script' => ''));
$correct_link = 'https://' . $link;
$this->assertTrue($italian_url == $correct_link, t('The url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
$this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
$is_https = $temp_https;
}
}

View File

@ -58,7 +58,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
// Check URL rewriting with a non-installed language.
$non_existing = language_default();
$non_existing->langcode = $this->randomName();
$this->checkUrl($non_existing, t('Path language is ignored if language is not installed.'), t('URL language negotiation does not work with non-installed languages'));
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages');
}
/**