Commit 6c028734 authored by jhodgdon's avatar jhodgdon

Issue #1797364 by dcam, lazysoundsystem, Lars Toomre, neetu morwani, izus,...

Issue #1797364 by dcam,  lazysoundsystem, Lars Toomre, neetu morwani, izus, boran, xjm: Remove t() from test asserts in locale module
parent a09093be
......@@ -125,7 +125,7 @@ function testContentTypeLanguageConfiguration() {
// Edit the content and ensure correct language is selected.
$path = 'node/' . $node->id() . '/edit';
$this->drupalGet($path);
$this->assertRaw('<option value="' . $langcode . '" selected="selected">' . $name . '</option>', t('Correct language selected.'));
$this->assertRaw('<option value="' . $langcode . '" selected="selected">' . $name . '</option>', 'Correct language selected.');
// Ensure we can change the node language.
$edit = array(
'langcode' => 'en',
......
......@@ -65,9 +65,9 @@ function testExportTranslation() {
), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', t('Exported French translation file.'));
$this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
// Ensure our imported translations exist in the file.
$this->assertRaw('msgstr "lundi"', t('French translations present in exported file.'));
$this->assertRaw('msgstr "lundi"', 'French translations present in exported file.');
// Import some more French translations which will be marked as customized.
$name = tempnam('temporary://', "po2_") . '.po';
......@@ -95,11 +95,11 @@ function testExportTranslation() {
), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', t('Exported French translation file with only customized strings.'));
$this->assertRaw('# French translation of Drupal', 'Exported French translation file with only customized strings.');
// Ensure the customized translations exist in the file.
$this->assertRaw('msgstr "janvier"', t('French custom translation present in exported file.'));
$this->assertRaw('msgstr "janvier"', 'French custom translation present in exported file.');
// Ensure no untranslated strings exist in the file.
$this->assertNoRaw('msgid "February"', t('Untranslated string not present in exported file.'));
$this->assertNoRaw('msgid "February"', 'Untranslated string not present in exported file.');
// Export only untranslated French translations.
$this->drupalPost('admin/config/regional/translate/export', array(
......@@ -110,11 +110,11 @@ function testExportTranslation() {
), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', t('Exported French translation file with only untranslated strings.'));
$this->assertRaw('# French translation of Drupal', 'Exported French translation file with only untranslated strings.');
// Ensure no customized translations exist in the file.
$this->assertNoRaw('msgstr "janvier"', t('French custom translation not present in exported file.'));
$this->assertNoRaw('msgstr "janvier"', 'French custom translation not present in exported file.');
// Ensure the untranslated strings exist in the file, and with right quotes.
$this->assertRaw($this->getUntranslatedString(), t('Empty string present in exported file.'));
$this->assertRaw($this->getUntranslatedString(), 'Empty string present in exported file.');
}
/**
......@@ -128,7 +128,7 @@ function testExportTranslationTemplateFile() {
// Get the translation template file.
$this->drupalPost('admin/config/regional/translate/export', array(), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# LANGUAGE translation of PROJECT', t('Exported translation template file.'));
$this->assertRaw('# LANGUAGE translation of PROJECT', 'Exported translation template file.');
}
/**
......
......@@ -8,6 +8,7 @@
namespace Drupal\locale\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\String;
/**
* Functional tests for JavaScript parsing for translatable strings.
......@@ -96,12 +97,12 @@ function testFileParsing() {
$args = array('%source' => $str, '%context' => $context);
// Make sure that the string was found in the file.
$this->assertTrue(isset($source_strings[$str]), t("Found source string: %source", $args));
$this->assertTrue(isset($source_strings[$str]), String::format("Found source string: %source", $args));
// Make sure that the proper context was matched.
$this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, strlen($context) > 0 ? t("Context for %source is %context", $args) : t("Context for %source is blank", $args));
$this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, strlen($context) > 0 ? String::format("Context for %source is %context", $args) : String::format("Context for %source is blank", $args));
}
$this->assertEqual(count($source_strings), count($test_strings), t("Found correct number of source strings."));
$this->assertEqual(count($source_strings), count($test_strings), "Found correct number of source strings.");
}
}
......@@ -38,6 +38,6 @@ public static function getInfo() {
public function testLibraryInfoAlter() {
drupal_add_library('system', 'jquery.ui.datepicker');
$scripts = drupal_get_js();
$this->assertTrue(strpos($scripts, 'locale.datepicker.js'), t('locale.datepicker.js added to scripts.'));
$this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');
}
}
......@@ -69,7 +69,7 @@ function testPathLanguageConfiguration() {
// Check that the "xx" front page is readily available because path prefix
// negotiation is pre-configured.
$this->drupalGet($prefix);
$this->assertText(t('Welcome to Drupal'), t('The "xx" front page is readibly available.'));
$this->assertText(t('Welcome to Drupal'), 'The "xx" front page is readibly available.');
// Create a node.
$node = $this->drupalCreateNode(array('type' => 'page'));
......@@ -95,11 +95,11 @@ function testPathLanguageConfiguration() {
// Confirm English language path alias works.
$this->drupalGet($english_path);
$this->assertText($node->label(), t('English alias works.'));
$this->assertText($node->label(), 'English alias works.');
// Confirm custom language path alias works.
$this->drupalGet($prefix . '/' . $custom_language_path);
$this->assertText($node->label(), t('Custom language alias works.'));
$this->assertText($node->label(), 'Custom language alias works.');
// Create a custom path.
$custom_path = $this->randomName(8);
......@@ -112,10 +112,10 @@ function testPathLanguageConfiguration() {
);
$this->container->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']);
$lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), 'en');
$this->assertEqual($english_path, $lookup_path, t('English language alias has priority.'));
$this->assertEqual($english_path, $lookup_path, 'English language alias has priority.');
// Same check for language 'xx'.
$lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), $prefix);
$this->assertEqual($custom_language_path, $lookup_path, t('Custom language alias has priority.'));
$this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.');
$this->container->get('path.crud')->delete($edit);
// Create language nodes to check priority of aliases.
......@@ -142,17 +142,17 @@ function testPathLanguageConfiguration() {
$this->drupalGet('<front>');
$custom_path_url = base_path() . $GLOBALS['script_path'] . $custom_path;
$elements = $this->xpath('//a[@href=:href and .=:title]', array(':href' => $custom_path_url, ':title' => $first_node->label()));
$this->assertTrue(!empty($elements), t('First node links to the path alias.'));
$this->assertTrue(!empty($elements), 'First node links to the path alias.');
$elements = $this->xpath('//a[@href=:href and .=:title]', array(':href' => $custom_path_url, ':title' => $second_node->label()));
$this->assertTrue(!empty($elements), t('Second node links to the path alias.'));
$this->assertTrue(!empty($elements), 'Second node links to the path alias.');
// Confirm that the custom path leads to the first node.
$this->drupalGet($custom_path);
$this->assertText($first_node->label(), t('Custom alias returns first node.'));
$this->assertText($first_node->label(), 'Custom alias returns first node.');
// Confirm that the custom path with prefix leads to the second node.
$this->drupalGet($prefix . '/' . $custom_path);
$this->assertText($second_node->label(), t('Custom alias with prefix returns second node.'));
$this->assertText($second_node->label(), 'Custom alias with prefix returns second node.');
}
}
......@@ -155,9 +155,9 @@ function testPluralEditExport() {
'langcode' => 'fr',
), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', t('Exported French translation file.'));
$this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
// Ensure our imported translations exist in the file.
$this->assertRaw("msgid \"Monday\"\nmsgstr \"lundi\"", t('French translations present in exported file.'));
$this->assertRaw("msgid \"Monday\"\nmsgstr \"lundi\"", 'French translations present in exported file.');
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"", 'Plural translations exported properly.');
......@@ -166,11 +166,11 @@ function testPluralEditExport() {
'langcode' => 'hr',
), t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# Croatian translation of Drupal', t('Exported Croatian translation file.'));
$this->assertRaw('# Croatian translation of Drupal', 'Exported Croatian translation file.');
// Ensure our imported translations exist in the file.
$this->assertRaw("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"", t('Croatian translations present in exported file.'));
$this->assertRaw("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"", 'Croatian translations present in exported file.');
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata\"\nmsgstr[2] \"@count sati\"", t('Plural translations exported properly.'));
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata\"\nmsgstr[2] \"@count sati\"", 'Plural translations exported properly.');
// Check if the source appears on the translation page.
$this->drupalGet('admin/config/regional/translate');
......@@ -256,15 +256,15 @@ function testPluralEditExport() {
), t('Export'));
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"", 'Edited French plural translations for hours exported properly.');
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"", t('Added French plural translations for days exported properly.'));
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"", 'Added French plural translations for days exported properly.');
// Get the Croatian translations.
$this->drupalPost('admin/config/regional/translate/export', array(
'langcode' => 'hr',
), t('Export'));
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"", t('Edited Croatian plural translations exported properly.'));
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"", t('Added Croatian plural translations exported properly.'));
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"", 'Edited Croatian plural translations exported properly.');
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"", 'Added Croatian plural translations exported properly.');
}
/**
......
......@@ -9,6 +9,7 @@
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Language\Language;
use Drupal\Component\Utility\String;
/**
* Locale uninstall with English UI functional test.
......@@ -68,7 +69,7 @@ function testUninstallProcess() {
global $user;
$user = drupal_anonymous_user();
$this->assertEqual(language(Language::TYPE_INTERFACE)->id, $this->langcode, t('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id)));
$this->assertEqual(language(Language::TYPE_INTERFACE)->id, $this->langcode, String::format('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id)));
// Enable multilingual workflow option for articles.
language_save_default_configuration('node', 'article', array('langcode' => 'site_default', 'language_show' => TRUE));
......@@ -89,7 +90,7 @@ function testUninstallProcess() {
$config = config('locale.settings');
$locale_javascripts = $this->container->get('state')->get('locale.translation.javascript') ?: array();
$js_file = 'public://' . $config->get('javascript.directory') . '/fr_' . $locale_javascripts['fr'] . '.js';
$this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('none'))));
$this->assertTrue($result = file_exists($js_file), String::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'none')));
// Disable string caching.
$config->set('cache_strings', 0)->save();
......@@ -115,31 +116,31 @@ function testUninstallProcess() {
// Visit the front page.
$this->drupalGet('');
// Check the init language logic.
$this->assertEqual(language(Language::TYPE_INTERFACE)->id, 'en', t('Language after uninstall: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id)));
$this->assertEqual(language(Language::TYPE_INTERFACE)->id, 'en', String::format('Language after uninstall: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id)));
// Check JavaScript files deletion.
$this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
$this->assertTrue($result = !file_exists($js_file), String::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
// Check language count.
$language_count = $this->container->get('state')->get('language_count') ?: 1;
$this->assertEqual($language_count, 1, t('Language count: %count', array('%count' => $language_count)));
$this->assertEqual($language_count, 1, String::format('Language count: %count', array('%count' => $language_count)));
// Check language negotiation.
require_once DRUPAL_ROOT . '/core/includes/language.inc';
$this->assertTrue(count(language_types_get_all()) == count(language_types_get_default()), t('Language types reset'));
$this->assertTrue(count(language_types_get_all()) == count(language_types_get_default()), 'Language types reset');
$language_negotiation = language_negotiation_method_get_first(Language::TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
$this->assertTrue($language_negotiation, String::format('Interface language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
$language_negotiation = language_negotiation_method_get_first(Language::TYPE_CONTENT) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('Content language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
$this->assertTrue($language_negotiation, String::format('Content language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
$language_negotiation = language_negotiation_method_get_first(Language::TYPE_URL) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('URL language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
$this->assertTrue($language_negotiation, String::format('URL language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
// Check language negotiation method settings.
$this->assertFalse(config('language.negotiation')->get('url.source'), t('URL language negotiation method indicator settings cleared.'));
$this->assertFalse(config('language.negotiation')->get('session.parameter'), t('Visit language negotiation method settings cleared.'));
$this->assertFalse(config('language.negotiation')->get('url.source'), 'URL language negotiation method indicator settings cleared.');
$this->assertFalse(config('language.negotiation')->get('session.parameter'), 'Visit language negotiation method settings cleared.');
// Check JavaScript parsed.
$javascript_parsed_count = count($this->container->get('state')->get('system.javascript_parsed') ?: array());
$this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count)));
$this->assertEqual($javascript_parsed_count, 0, String::format('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count)));
}
}
......@@ -8,6 +8,7 @@
namespace Drupal\locale\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\String;
/**
* Tests for update translations.
......@@ -81,7 +82,7 @@ protected function addLanguage($langcode) {
$edit = array('predefined_langcode' => $langcode);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
drupal_static_reset('language_list');
$this->assertTrue(language_load($langcode), t('Language %langcode added.', array('%langcode' => $langcode)));
$this->assertTrue(language_load($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode)));
}
/**
......
......@@ -443,8 +443,8 @@ function testEnableCustomLanguage() {
// Ensure the translation file is automatically imported when the language
// was added.
$this->assertText(t('One translation file imported.'), t('Language file automatically imported.'));
$this->assertText(t('One translation string was skipped because of disallowed or malformed HTML'), t('Language file automatically imported.'));
$this->assertText(t('One translation file imported.'), 'Language file automatically imported.');
$this->assertText(t('One translation string was skipped because of disallowed or malformed HTML'), 'Language file automatically imported.');
// Ensure the strings were successfully imported.
$search = array(
......@@ -453,7 +453,7 @@ function testEnableCustomLanguage() {
'translation' => 'translated',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), t('String successfully imported.'));
$this->assertNoText(t('No strings available.'), 'String successfully imported.');
// Ensure the multiline string was imported.
$search = array(
......@@ -462,7 +462,7 @@ function testEnableCustomLanguage() {
'translation' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText('Multiline translation string to make sure that import works with it.', t('String successfully imported.'));
$this->assertText('Multiline translation string to make sure that import works with it.', 'String successfully imported.');
// Ensure 'Allowed HTML source string' was imported but the translation for
// 'Another allowed HTML source string' was not because it contains invalid
......@@ -473,8 +473,8 @@ function testEnableCustomLanguage() {
'translation' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->assertText('Allowed HTML source string', t('String successfully imported.'));
$this->assertNoText('Another allowed HTML source string', t('String with disallowed translation not imported.'));
$this->assertText('Allowed HTML source string', 'String successfully imported.');
$this->assertNoText('Another allowed HTML source string', 'String with disallowed translation not imported.');
}
}
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