From 8ca38526046fb6623cab838f0c01c9493023c839 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Thu, 14 Mar 2024 15:32:12 +0000
Subject: [PATCH] fixes #3578

Closes #3578

Merge request studip/studip!2474
---
 lib/navigation/Navigation.php             | 27 +++++++----------------
 tests/unit/lib/classes/NavigationTest.php |  6 ++---
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/lib/navigation/Navigation.php b/lib/navigation/Navigation.php
index 50ea94f71c4..3c02e86b317 100644
--- a/lib/navigation/Navigation.php
+++ b/lib/navigation/Navigation.php
@@ -352,38 +352,27 @@ class Navigation implements IteratorAggregate
     }
 
     /**
-     * Set the image of this navigation item. Additional HTML
-     * attributes can be passed using the $options parameter
-     * (like 'style' or 'onclick').
+     * Set the image of this navigation item.
      *
-     * @param Icon   $image            an instance of class Icon depicting this item
-     * @param array  $link_attributes  additional link attributes
+     * @param \Icon|null $image an instance of class Icon depicting this item
+     *                          or null to remove the image
      */
-    public function setImage(\Icon $image = null, $linkAttributes = [])
+    public function setImage(?\Icon $image)
     {
         $this->image = $image;
-        $this->link_attributes = array_merge(
-            $this->link_attributes,
-            $linkAttributes
-        );
     }
 
     /**
      * Set the image for the active state of this navigation item.
      * If no active image is set, the normal image is used for the
-     * active state. Additional HTML attributes can be passed using
-     * the $options parameter (like 'style' or 'onclick').
+     * active state.
      *
-     * @param Icon   $image            an instance of class Icon depicting this item
-     * @param array  $link_attributes  additional link attributes
+     * @param \Icon|null $image an instance of class Icon depicting this item
+     *                          or null to remove the image
      */
-    public function setActiveImage(\Icon $image = null, $linkAttributes = [])
+    public function setActiveImage(?\Icon $image)
     {
         $this->active_image = $image;
-        $this->link_attributes = array_merge(
-            $this->link_attributes,
-            $linkAttributes
-        );
     }
 
     /**
diff --git a/tests/unit/lib/classes/NavigationTest.php b/tests/unit/lib/classes/NavigationTest.php
index a90e386702f..a67b355b235 100644
--- a/tests/unit/lib/classes/NavigationTest.php
+++ b/tests/unit/lib/classes/NavigationTest.php
@@ -44,14 +44,12 @@ class NavigationTest extends \Codeception\Test\Unit
         $navigation = new Navigation('test', 'foo.php');
         $this->assertNull($navigation->getImage());
 
-        $icon = Icon::create('foo', 'clickable');
-        $link_attrs = ['alt' => 'foo'];
+        $icon = Icon::create('foo', Icon::ROLE_CLICKABLE);
 
-        $navigation->setImage($icon, $link_attrs);
+        $navigation->setImage($icon);
 
         $this->assertTrue($navigation->isVisible(true));
         $this->assertEquals($icon, $navigation->getImage());
-        $this->assertEquals($link_attrs, $navigation->getLinkAttributes());
     }
 
     public function testActiveImage ()
-- 
GitLab