public function testAttributes()
 {
     $menuItem = new CMSMenuItem('Foo', 'foo');
     $exampleAttributes = array('title' => 'foo bar', 'disabled' => true, 'data-foo' => '<something>');
     $this->assertEquals('title="foo bar" disabled="disabled" data-foo="&lt;something&gt;"', $menuItem->getAttributesHTML($exampleAttributes), 'Attributes appear correctly when passed as an argument');
     $emptyAttributes = array('empty' => '');
     $this->assertEquals('', $menuItem->getAttributesHTML($emptyAttributes), 'No attributes are output when argument values are empty');
     $this->assertEquals('', $menuItem->getAttributesHTML('some string'), 'getAttributesHTML() ignores a string argument');
     // Set attributes as class property
     $menuItem->setAttributes($exampleAttributes);
     $this->assertEquals('title="foo bar" disabled="disabled" data-foo="&lt;something&gt;"', $menuItem->getAttributesHTML(), 'Attributes appear correctly when using setAttributes()');
     $this->assertEquals('title="foo bar" disabled="disabled" data-foo="&lt;something&gt;"', $menuItem->getAttributesHTML('foo bar'), 'getAttributesHTML() ignores a string argument and falls back to class property');
 }
 /**
  * Replace a navigation item to the main administration menu showing in the top bar.
  *
  * @param string $code Unique identifier for this menu item (e.g. used by {@link replace_menu_item()} and
  * 					{@link remove_menu_item}. Also used as a CSS-class for icon customization.
  * @param string $menuTitle Localized title showing in the menu bar
  * @param string $url A relative URL that will be linked in the menu bar.
  * 					Make sure to add a matching route via {@link Director::$rules} to this url.
  * @param string $controllerClass The controller class for this menu, used to check permisssions.
  * 					If blank, it's assumed that this is public, and always shown to users who
  * 					have the rights to access some other part of the admin area.
  * @param array $attributes an array of attributes to include on the link.
  *
  * @return boolean Success
  */
 public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null)
 {
     $item = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority);
     if ($attributes) {
         $item->setAttributes($attributes);
     }
     self::$menu_item_changes[] = array('type' => 'add', 'code' => $code, 'item' => $item);
 }