summaryrefslogtreecommitdiff
path: root/modules/locale/locale.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/locale/locale.test')
-rw-r--r--modules/locale/locale.test71
1 files changed, 71 insertions, 0 deletions
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index b03b85d0d..9a800303a 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1618,3 +1618,74 @@ class UILanguageNegotiationTest extends DrupalWebTestCase {
$this->assertText($test['expect'], $test['message']);
}
}
+
+/**
+ * Functional tests for localizing date formats.
+ */
+class LocalizeDateFormatsFunctionalTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Localize date formats',
+ 'description' => 'Tests for the localization of date formats.',
+ 'group' => 'Locale',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('locale');
+
+ // Create and login user.
+ $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'create article content'));
+ $this->drupalLogin($admin_user);
+ }
+
+ /**
+ * Functional tests for localizing date formats.
+ */
+ function testLocalizeDateFormats() {
+ // Add language.
+ $edit = array(
+ 'langcode' => 'fr',
+ );
+ $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+
+ // Set language negotiation.
+ $edit = array(
+ 'language[enabled][locale-url]' => TRUE,
+ 'language_interface[enabled][locale-url]' => TRUE,
+ );
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+
+ // Configure date formats.
+ $this->drupalGet('admin/config/regional/date-time/locale');
+ $this->assertText('Français', 'Configured languages appear.');
+ $edit = array(
+ 'date_format_long' => 'd.m.Y - H:i',
+ 'date_format_medium' => 'd.m.Y - H:i',
+ 'date_format_short' => 'd.m.Y - H:i',
+ );
+ $this->drupalPost('admin/config/regional/date-time/locale/fr/edit', $edit, t('Save configuration'));
+ $this->assertText(t('Configuration saved.'), 'French date formats updated.');
+ $edit = array(
+ 'date_format_long' => 'j M Y - g:ia',
+ 'date_format_medium' => 'j M Y - g:ia',
+ 'date_format_short' => 'j M Y - g:ia',
+ );
+ $this->drupalPost('admin/config/regional/date-time/locale/en/edit', $edit, t('Save configuration'));
+ $this->assertText(t('Configuration saved.'), 'English date formats updated.');
+
+ // Create node content.
+ $node = $this->drupalCreateNode(array('type' => 'article'));
+
+ // Configure format for the node posted date changes with the language.
+ $this->drupalGet('node/' . $node->nid);
+ $english_date = format_date($node->created, 'custom', 'j M Y');
+ $this->assertText($english_date, t('English date format appears'));
+ $this->drupalGet('fr/node/' . $node->nid);
+ $french_date = format_date($node->created, 'custom', 'd.m.Y');
+ $this->assertText($french_date, t('French date format appears'));
+ }
+}
+
+