From 32ff106117b69cee534701842ed6888b6e4c23db Sat, 27 Jul 2013 14:19:50 +0200 From: hass Date: Sat, 27 Jul 2013 14:19:05 +0200 Subject: [PATCH] Issue #2028643 by hass: CSS files order is broken diff --git a/modules/locale/locale.module b/modules/locale/locale.module index b60c531..768fead 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -972,7 +972,7 @@ // Replicate the same item, but with the RTL path and a little larger // weight so that it appears directly after the original CSS file. $item['data'] = $rtl_path; - $item['weight'] += 0.01; + $item['weight'] += 0.0001; $css[$rtl_path] = $item; } } diff --git a/modules/locale/locale.test b/modules/locale/locale.test index d9caa9e..cd8faeb 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -3096,3 +3096,48 @@ } } +/** + * Functional tests for CSS alter functions. + */ +class LocaleCSSAlterTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'CSS altering', + 'description' => 'Test CSS alter functions.', + 'group' => 'Locale', + ); + } + + function setUp() { + parent::setUp('locale'); + } + + /** + * Verifies that -rtl.css file is added directly after LTR .css file. + */ + function testCSSFilesOrderInRTLMode() { + global $base_url; + + // User to add and remove language. + $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); + + // Log in as admin. + $this->drupalLogin($admin_user); + + // Install the Arabic language (which is RTL) and configure as the default. + $edit = array(); + $edit['langcode'] = 'ar'; + $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); + + $edit = array(); + $edit['site_default'] = 'ar'; + $this->drupalPost(NULL, $edit, t('Save configuration')); + + // Verify that the -rtl.css file is added directly after LTR file. + $this->drupalGet(''); + $query_string = '?' . variable_get('css_js_query_string', '0'); + $this->assertRaw('@import url("' . $base_url . '/modules/system/system.base.css' . $query_string . '");' . "\n" . '@import url("' . $base_url . '/modules/system/system.base-rtl.css' . $query_string . '");' . "\n", t('CSS: system.base-rtl.css is added directly after system.base.css.')); + $this->assertRaw('@import url("' . $base_url . '/modules/system/system.menus.css' . $query_string . '");' . "\n" . '@import url("' . $base_url . '/modules/system/system.menus-rtl.css' . $query_string . '");' . "\n", t('CSS: system.menus-rtl.css is added directly after system.menus.css.')); + $this->assertRaw('@import url("' . $base_url . '/modules/system/system.messages.css' . $query_string . '");' . "\n" . '@import url("' . $base_url . '/modules/system/system.messages-rtl.css' . $query_string . '");' . "\n", t('CSS: system.messages-rtl.css is added directly after system.messages.css.')); + } +}