aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/studip_controller.php2
-rw-r--r--tests/unit/lib/classes/StudipControllerTest.php26
2 files changed, 27 insertions, 1 deletions
diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php
index cddb82e..a08a946 100644
--- a/app/controllers/studip_controller.php
+++ b/app/controllers/studip_controller.php
@@ -717,7 +717,7 @@ abstract class StudipController extends Trails_Controller
public function action_url($action)
{
$arguments = func_get_args();
- array_unshift($arguments, $this->controller_path());
+ $arguments[0] = $this->controller_path() . '/' . $arguments[0];
return $this->url_for(...$arguments);
}
diff --git a/tests/unit/lib/classes/StudipControllerTest.php b/tests/unit/lib/classes/StudipControllerTest.php
index 3675f58..a7009fe 100644
--- a/tests/unit/lib/classes/StudipControllerTest.php
+++ b/tests/unit/lib/classes/StudipControllerTest.php
@@ -66,6 +66,19 @@ final class StudipControllerTest extends Codeception\Test\Unit
}
/**
+ * @dataProvider actionUrlProvider
+ * @covers StudipController::action_url
+ */
+ public function testActionUrl(string $expected, ...$args): void
+ {
+ $url = $this->getController()->action_url(...$args);
+ $this->assertEquals(
+ $expected,
+ $this->getRelativeURL($url)
+ );
+ }
+
+ /**
* @dataProvider RedirectProvider
* @covers StudipController::redirect
*/
@@ -192,6 +205,19 @@ final class StudipControllerTest extends Codeception\Test\Unit
];
}
+ public function actionUrlProvider(): array
+ {
+ return [
+ 'action' => ['dispatch.php/studip_controller_test/foo', 'foo'],
+ 'action-and-parameter' => ['dispatch.php/studip_controller_test/foo/23', 'foo/23'],
+ 'action-and-parameters' => ['dispatch.php/studip_controller_test/foo/23?bar=42', 'foo/23', ['bar' => 42]],
+
+ 'fragment' => ['dispatch.php/studip_controller_test/foo/42/23#jump', 'foo/42/23#jump'],
+ 'fragment-and-parameters' => ['dispatch.php/studip_controller_test/foo/42/23#jump', 'foo#jump', 42, 23],
+ 'url-encoding-parameters' => ['dispatch.php/studip_controller_test/foo/%3Fabc/%2F', 'foo', '?abc', '/'],
+ ];
+ }
+
public function RedirectProvider(): array
{
$result = $this->UrlForProvider();