diff --git a/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarMenuTranslationTest.php b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarMenuTranslationTest.php new file mode 100644 index 0000000..2012ed9 --- /dev/null +++ b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarMenuTranslationTest.php @@ -0,0 +1,85 @@ + 'Toolbar menu translation', + 'description' => "Tests that toolbar classes don't change when adding a translation", + 'group' => 'Toolbar', + ); + } + + function setUp() { + parent::setUp(); + + // Create an administrative user and log it in. + $this->admin_user = $this->drupalCreateUser(array('access toolbar', 'translate interface', 'administer languages', 'access administration pages')); + $this->drupalLogin($this->admin_user); + } + + /** + * Tests that toolbar classes don't change when adding a translation. + */ + function testToolbarClasses() { + $langcode = 'xx'; + // The English name for the language. + $name = $this->randomName(16); + + // Add custom language. + $edit = array( + 'predefined_langcode' => 'custom', + 'langcode' => $langcode, + 'name' => $name, + 'direction' => '0', + ); + $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); + + // Change the default language. + $edit = array( + 'site_default' => $langcode, + ); + $this->drupalPost(NULL, $edit, t('Save configuration')); + + // Search for a menu item. For example 'Structure' + $menu_item = 'Structure'; + t($menu_item, array(), array('langcode' => $langcode)); + $search = array( + 'string' => $menu_item, + 'langcode' => $langcode, + 'translation' => 'untranslated', + ); + $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter')); + + // Translate the menu item + $textarea = current($this->xpath('//textarea')); + $lid = (string) $textarea[0]['name']; + $edit = array( + $lid => $this->randomName(), + ); + $this->drupalPost('admin/config/regional/translate/translate', $edit, t('Save translations')); + + // Tests if the menu item class changes + $xpath = $this->xpath('//a[@class="icon-structure"]'); + $this->assertEqual(count($xpath), 1, "The menu item class doesn't change."); + } +} diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index e543326..9096485 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -391,7 +391,7 @@ function toolbar_menu_navigation_links(&$tree) { 'id' => 'toolbar-link-' . str_replace(array('/', '<', '>'), array('-', '', ''), $item['link']['link_path']), 'class' => array( 'icon', - 'icon-' . strtolower(str_replace(' ', '-', $item['link']['title'])), + 'icon-' . strtolower(str_replace(' ', '-', $item['link']['link_title'])), ), ); }