summaryrefslogtreecommitdiff
path: root/modules/locale
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-17 08:40:18 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-17 08:40:18 -0700
commita545c308095d04474147b0e47f3f9e4db8063a85 (patch)
tree313053c63403dacdf211bd6cf164197259e13967 /modules/locale
parent6f300a6cd76b0c9797cda77ce5abf63e172cd254 (diff)
downloadbrdo-a545c308095d04474147b0e47f3f9e4db8063a85.tar.gz
brdo-a545c308095d04474147b0e47f3f9e4db8063a85.tar.bz2
Issue #1281932 by loganfsmyth, bfroehle, Gábor Hojtsy: Convert Drupal.t and Drupal.formatPlural regular expressions to extended form.
Diffstat (limited to 'modules/locale')
-rw-r--r--modules/locale/locale.test67
1 files changed, 67 insertions, 0 deletions
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 6d8ae94b2..064a9b936 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -180,6 +180,73 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
}
/**
+ * Functional tests for JavaScript parsing for translatable strings.
+ */
+class LocaleJavascriptTranslationTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Javascript translation',
+ 'description' => 'Tests parsing js files for translatable strings',
+ 'group' => 'Locale',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('locale', 'locale_test');
+ }
+
+ function testFileParsing() {
+
+ $filename = drupal_get_path('module', 'locale_test') . '/locale_test.js';
+
+ // Parse the file to look for source strings.
+ _locale_parse_js_file($filename);
+
+ // Get all of the source strings that were found.
+ $source_strings = db_select('locales_source', 's')
+ ->fields('s', array('source', 'lid'))
+ ->condition('s.location', $filename)
+ ->execute()
+ ->fetchAllKeyed();
+
+ // List of all strings that should be in the file.
+ $test_strings = array(
+ "Standard Call t",
+ "Whitespace Call t",
+
+ "Single Quote t",
+ "Single Quote \\'Escaped\\' t",
+ "Single Quote Concat strings t",
+
+ "Double Quote t",
+ "Double Quote \\\"Escaped\\\" t",
+ "Double Quote Concat strings t",
+
+ "Standard Call plural",
+ "Standard Call @count plural",
+ "Whitespace Call plural",
+ "Whitespace Call @count plural",
+
+ "Single Quote plural",
+ "Single Quote @count plural",
+ "Single Quote \\'Escaped\\' plural",
+ "Single Quote \\'Escaped\\' @count plural",
+
+ "Double Quote plural",
+ "Double Quote @count plural",
+ "Double Quote \\\"Escaped\\\" plural",
+ "Double Quote \\\"Escaped\\\" @count plural",
+ );
+
+ // Assert that all strings were found properly.
+ foreach ($test_strings as $str) {
+ $this->assertTrue(isset($source_strings[$str]), t("Found source string: %source", array('%source' => $str)));
+ }
+
+ $this->assertEqual(count($source_strings), count($test_strings), t("Found correct number of source strings."));
+ }
+}
+/**
* Functional test for string translation and validation.
*/
class LocaleTranslationFunctionalTest extends DrupalWebTestCase {