aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2022-07-15 10:22:26 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2022-07-15 10:22:26 +0200
commit4a66ff3c48c8388cdc164e7ba3ef26b2f4c5ec75 (patch)
treeb4595ff38e66a3daec5459aadf8ea545e0bc8b4f /tests
parentca923e5e1d8ed1ab1e3fe88b3a08c2170096d857 (diff)
fix fallout from 769675071b44cff1f699396270b378d189ada866 and provide test for variable assignments in StudipController, re #1328
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/lib/classes/StudipControllerTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/StudipControllerTest.php b/tests/unit/lib/classes/StudipControllerTest.php
index 5321166..2b25bc4 100644
--- a/tests/unit/lib/classes/StudipControllerTest.php
+++ b/tests/unit/lib/classes/StudipControllerTest.php
@@ -182,6 +182,42 @@ final class StudipControllerTest extends Codeception\Test\Unit
$this->getController()->relocate(...$args);
}
+ public function testVariableAssignment(): void
+ {
+ $controller = $this->getController();
+
+ // Set and test assignments
+ $controller->foo = 'bar';
+ $this->assertEquals('bar', $controller->foo);
+
+ $controller->bar = 42;
+ $this->assertEquals(42, $controller->bar);
+
+ $controller->baz = [];
+ $controller->baz[] = 23;
+ $this->assertEquals([23], $controller->baz);
+
+ // Test fetching all variables
+ $variables = $controller->get_assigned_variables();
+
+ $this->assertIsArray($variables);
+
+ // - Implicit variables
+ $this->assertArrayHasKey('controller', $variables);
+ $this->assertArrayHasKey('current_action', $variables);
+
+ // - Explicit variables
+ $this->assertArrayHasKey('foo', $variables);
+ $this->assertEquals('bar', $variables['foo']);
+
+ $this->assertArrayHasKey('bar', $variables);
+ $this->assertEquals(42, $variables['bar']);
+
+ $this->assertArrayHasKey('baz', $variables);
+ $this->assertCount(1, $variables['baz']);
+ $this->assertEquals([23], $variables['baz']);
+ }
+
/**
* Returns a relative url for Stud.IP if given url matches.
*/