summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/modules/locale/tests
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.26/modules/locale/tests')
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.js46
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.module242
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/translations/test.xx.po28
4 files changed, 328 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.info b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.info
new file mode 100644
index 0000000..7506100
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.info
@@ -0,0 +1,12 @@
+name = "Locale Test"
+description = "Support module for the locale layer tests."
+core = 7.x
+package = Testing
+version = VERSION
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.js b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.js
new file mode 100644
index 0000000..0693bca
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.js
@@ -0,0 +1,46 @@
+
+Drupal.t("Standard Call t");
+Drupal
+.
+t
+(
+"Whitespace Call t"
+)
+;
+
+Drupal.t('Single Quote t');
+Drupal.t('Single Quote \'Escaped\' t');
+Drupal.t('Single Quote ' + 'Concat ' + 'strings ' + 't');
+
+Drupal.t("Double Quote t");
+Drupal.t("Double Quote \"Escaped\" t");
+Drupal.t("Double Quote " + "Concat " + "strings " + "t");
+
+Drupal.t("Context Unquoted t", {}, {context: "Context string unquoted"});
+Drupal.t("Context Single Quoted t", {}, {'context': "Context string single quoted"});
+Drupal.t("Context Double Quoted t", {}, {"context": "Context string double quoted"});
+
+Drupal.t("Context !key Args t", {'!key': 'value'}, {context: "Context string"});
+
+Drupal.formatPlural(1, "Standard Call plural", "Standard Call @count plural");
+Drupal
+.
+formatPlural
+(
+1,
+"Whitespace Call plural",
+"Whitespace Call @count plural"
+)
+;
+
+Drupal.formatPlural(1, 'Single Quote plural', 'Single Quote @count plural');
+Drupal.formatPlural(1, 'Single Quote \'Escaped\' plural', 'Single Quote \'Escaped\' @count plural');
+
+Drupal.formatPlural(1, "Double Quote plural", "Double Quote @count plural");
+Drupal.formatPlural(1, "Double Quote \"Escaped\" plural", "Double Quote \"Escaped\" @count plural");
+
+Drupal.formatPlural(1, "Context Unquoted plural", "Context Unquoted @count plural", {}, {context: "Context string unquoted"});
+Drupal.formatPlural(1, "Context Single Quoted plural", "Context Single Quoted @count plural", {}, {'context': "Context string single quoted"});
+Drupal.formatPlural(1, "Context Double Quoted plural", "Context Double Quoted @count plural", {}, {"context": "Context string double quoted"});
+
+Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", {'!key': 'value'}, {context: "Context string"});
diff --git a/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.module b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.module
new file mode 100644
index 0000000..64f4aed
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.module
@@ -0,0 +1,242 @@
+<?php
+
+/**
+ * @file
+ * Mock module for locale layer tests.
+ */
+
+/**
+ * Implements hook_locale().
+ */
+function locale_test_locale($op = 'groups') {
+ switch ($op) {
+ case 'groups':
+ return array('custom' => t('Custom'));
+ }
+}
+
+/**
+ * Implements hook_boot().
+ *
+ * For testing domain language negotiation, we fake it by setting
+ * the HTTP_HOST here
+ */
+function locale_test_boot() {
+ if (variable_get('locale_test_domain')) {
+ $_SERVER['HTTP_HOST'] = variable_get('locale_test_domain');
+ }
+}
+
+/**
+ * Implements hook_init().
+ */
+function locale_test_init() {
+ locale_test_store_language_negotiation();
+ if (isset($GLOBALS['language']) && isset($GLOBALS['language']->provider)) {
+ drupal_set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language']->provider)));
+ }
+}
+
+/**
+ * Implements hook_language_types_info().
+ */
+function locale_test_language_types_info() {
+ if (variable_get('locale_test_language_types', FALSE)) {
+ return array(
+ 'test_language_type' => array(
+ 'name' => t('Test'),
+ 'description' => t('A test language type.'),
+ ),
+ 'fixed_test_language_type' => array(
+ 'fixed' => array('test_language_provider'),
+ ),
+ );
+ }
+}
+
+/**
+ * Implements hook_menu().
+ *
+ * @return array
+ */
+function locale_test_menu() {
+ $items = array();
+ $items['locale_test_plural_format_page'] = array(
+ 'page callback' => 'locale_test_plural_format_page',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+}
+
+/**
+ * Implements hook_language_types_info_alter().
+ */
+function locale_test_language_types_info_alter(array &$language_types) {
+ if (variable_get('locale_test_content_language_type', FALSE)) {
+ unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
+ }
+}
+
+/**
+ * Implements hook_language_negotiation_info().
+ */
+function locale_test_language_negotiation_info() {
+ if (variable_get('locale_test_language_negotiation_info', FALSE)) {
+ $info = array(
+ 'callbacks' => array(
+ 'language' => 'locale_test_language_provider',
+ ),
+ 'file' => drupal_get_path('module', 'locale_test') .'/locale_test.module',
+ 'weight' => -10,
+ 'description' => t('This is a test language provider.'),
+ );
+
+ return array(
+ 'test_language_provider' => array(
+ 'name' => t('Test'),
+ 'types' => array(LANGUAGE_TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'),
+ ) + $info,
+ 'test_language_provider_ts' => array(
+ 'name' => t('Type-specific test'),
+ 'types' => array('test_language_type'),
+ ) + $info,
+ );
+ }
+}
+
+/**
+ * Implements hook_language_negotiation_info_alter().
+ */
+function locale_test_language_negotiation_info_alter(array &$language_providers) {
+ if (variable_get('locale_test_language_negotiation_info_alter', FALSE)) {
+ unset($language_providers[LOCALE_LANGUAGE_NEGOTIATION_INTERFACE]);
+ }
+}
+
+/**
+ * Store the last negotiated languages.
+ */
+function locale_test_store_language_negotiation() {
+ $last = array();
+ foreach (language_types() as $type) {
+ $last[$type] = $GLOBALS[$type]->language;
+ }
+ variable_set('locale_test_language_negotiation_last', $last);
+}
+
+/**
+ * Test language provider.
+ */
+function locale_test_language_provider($languages) {
+ return 'it';
+}
+
+/**
+ * Returns markup for locale_get_plural testing.
+ *
+ * @return array
+ */
+function locale_test_plural_format_page() {
+ $tests = _locale_test_plural_format_tests();
+ $result = array();
+ foreach ($tests as $test) {
+ $string_param = array(
+ '@lang' => $test['language'],
+ '@locale_get_plural' => locale_get_plural($test['count'], $test['language'])
+ );
+ $result[] = array(
+ '#prefix' => '<br/>',
+ '#markup' => format_string('Language: @lang, locale_get_plural: @locale_get_plural.', $string_param),
+ );
+ }
+ return $result;
+}
+
+/**
+ * Helper function with list of test cases
+ *
+ * @return array
+ */
+function _locale_test_plural_format_tests() {
+ return array(
+ // Test data for English (no formula present).
+ array(
+ 'count' => 1,
+ 'language' => 'en',
+ 'expected-result' => 0,
+ ),
+ array(
+ 'count' => 0,
+ 'language' => 'en',
+ 'expected-result' => 1,
+ ),
+ array(
+ 'count' => 5,
+ 'language' => 'en',
+ 'expected-result' => 1,
+ ),
+
+ // Test data for French (simpler formula).
+ array(
+ 'count' => 1,
+ 'language' => 'fr',
+ 'expected-result' => 0,
+ ),
+ array(
+ 'count' => 0,
+ 'language' => 'fr',
+ 'expected-result' => 1,
+ ),
+ array(
+ 'count' => 5,
+ 'language' => 'fr',
+ 'expected-result' => 1,
+ ),
+
+ // Test data for Croatian (more complex formula).
+ array(
+ 'count' => 1,
+ 'language' => 'hr',
+ 'expected-result' => 0,
+ ),
+ array(
+ 'count' => 21,
+ 'language' => 'hr',
+ 'expected-result' => 0,
+ ),
+ array(
+ 'count' => 0,
+ 'language' => 'hr',
+ 'expected-result' => 2,
+ ),
+ array(
+ 'count' => 2,
+ 'language' => 'hr',
+ 'expected-result' => 1,
+ ),
+ array(
+ 'count' => 8,
+ 'language' => 'hr',
+ 'expected-result' => 2,
+ ),
+
+ // Test data for Hungarian (nonexistent language).
+ array(
+ 'count' => 1,
+ 'language' => 'hu',
+ 'expected-result' => -1,
+ ),
+ array(
+ 'count' => 21,
+ 'language' => 'hu',
+ 'expected-result' => -1,
+ ),
+ array(
+ 'count' => 0,
+ 'language' => 'hu',
+ 'expected-result' => -1,
+ ),
+ );
+}
diff --git a/kolab.org/www/drupal-7.26/modules/locale/tests/translations/test.xx.po b/kolab.org/www/drupal-7.26/modules/locale/tests/translations/test.xx.po
new file mode 100644
index 0000000..659a6e3
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/locale/tests/translations/test.xx.po
@@ -0,0 +1,28 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Drupal 7\\n"
+"MIME-Version: 1.0\\n"
+"Content-Type: text/plain; charset=UTF-8\\n"
+"Content-Transfer-Encoding: 8bit\\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\\n"
+
+msgid "Monday"
+msgstr "lundi"
+
+msgid "Tuesday"
+msgstr "mardi"
+
+msgid "Wednesday"
+msgstr "mercredi"
+
+msgid "Thursday"
+msgstr "jeudi"
+
+msgid "Friday"
+msgstr "vendredi"
+
+msgid "Saturday"
+msgstr "samedi"
+
+msgid "Sunday"
+msgstr "dimanche"