aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-03-11 15:27:13 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2023-03-11 15:27:13 +0000
commit57d455a77c054be53b463a842d66fa8508d40c53 (patch)
tree08ebe1b7df523f8cf50967ed383f773fbfcb0af4 /tests
parent0da036073b530a8ca2316c0525d5a402ccd088b8 (diff)
allow forcing of rendering mode for ActionMenu (regardless of configured threshold) and add basic tests, fixes #2210
Closes #2210 Merge request studip/studip!1452
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/lib/classes/ActionMenuTest.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/ActionMenuTest.php b/tests/unit/lib/classes/ActionMenuTest.php
new file mode 100644
index 0000000..ece2c4e
--- /dev/null
+++ b/tests/unit/lib/classes/ActionMenuTest.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
+ * @since Stud.IP 5.4
+ */
+class ActionMenuTest extends \Codeception\Test\Unit
+{
+ public function setup(): void
+ {
+ Config::set(new Config(['ACTION_MENU_THRESHOLD' => 1]));
+ }
+
+ public function testClassShouldExist(): void
+ {
+ $this->assertTrue(class_exists(ActionMenu::class));
+ }
+
+ /**
+ * @covers ActionMenu::get
+ */
+ public function testInstanceGeneration(): void
+ {
+ $actionmenu = ActionMenu::get();
+
+ $this->assertInstanceOf(ActionMenu::class, $actionmenu);
+ $this->assertNotSame($actionmenu, ActionMenu::get());
+ }
+
+ public function testThreshold(): void
+ {
+ $actionmenu = ActionMenu::get();
+
+ $this->assertEquals(ActionMenu::RENDERING_MODE_ICONS, $actionmenu->getRenderingMode());
+
+ $actionmenu->addLink('#1', 'foo');
+ $this->assertEquals(ActionMenu::RENDERING_MODE_ICONS, $actionmenu->getRenderingMode());
+
+ $actionmenu->addLink('#2', 'bar');
+ $this->assertEquals(ActionMenu::RENDERING_MODE_MENU, $actionmenu->getRenderingMode());
+ }
+
+ /**
+ * @covers ActionMenu::setRenderingMode
+ * @covers ActionMenu::getRenderingMode
+ */
+ public function testForcingOfRenderingMode(): void
+ {
+ $actionmenu = ActionMenu::get();
+ $this->assertEquals(ActionMenu::RENDERING_MODE_ICONS, $actionmenu->getRenderingMode());
+
+ $actionmenu->setRenderingMode(ActionMenu::RENDERING_MODE_ICONS);
+ $this->assertEquals(ActionMenu::RENDERING_MODE_ICONS, $actionmenu->getRenderingMode());
+
+ $actionmenu->setRenderingMode(ActionMenu::RENDERING_MODE_MENU);
+ $this->assertEquals(ActionMenu::RENDERING_MODE_MENU, $actionmenu->getRenderingMode());
+
+ $actionmenu->setRenderingMode(null);
+ $this->assertEquals(ActionMenu::RENDERING_MODE_ICONS, $actionmenu->getRenderingMode());
+ }
+}