Skip to content
Snippets Groups Projects
Commit b7b4e67c authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

fix path handling in `action_url()`, fixes #1105

Closes #1105

Merge request studip/studip!661
parent 972e8b89
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -65,6 +65,19 @@ final class StudipControllerTest extends Codeception\Test\Unit
$this->getController()->url_for(...$args);
}
/**
* @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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment