diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-02-21 11:42:06 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-02-21 11:42:06 +0000 |
| commit | 2c384d9cb5b59432772747ec85a86bd86eecbb11 (patch) | |
| tree | b313c43a71773b9bfbde51a7716e2c578e9b6eeb /tests/unit/lib/classes/StudipControllerTest.php | |
| parent | 462a4673c3d2402d643f2dc5bedaf6a6230ec8b1 (diff) | |
allow no parameters for url_for(), fixes #642
Diffstat (limited to 'tests/unit/lib/classes/StudipControllerTest.php')
| -rw-r--r-- | tests/unit/lib/classes/StudipControllerTest.php | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/tests/unit/lib/classes/StudipControllerTest.php b/tests/unit/lib/classes/StudipControllerTest.php index db2d659..fae7628 100644 --- a/tests/unit/lib/classes/StudipControllerTest.php +++ b/tests/unit/lib/classes/StudipControllerTest.php @@ -12,14 +12,6 @@ final class StudipControllerTest extends Codeception\Test\Unit { private $old_uri; - public static function setUpBeforeClass(): void - { - parent::setUpBeforeClass(); - - require_once 'vendor/trails/trails-abridged.php'; - require_once 'app/controllers/studip_controller.php'; - } - public function setUp(): void { parent::setUp(); @@ -47,9 +39,7 @@ final class StudipControllerTest extends Codeception\Test\Unit private function getController(): StudipController { $dispatcher = $this->getDispatcher(); - return new class($dispatcher) extends StudipController { - - }; + return new StudipControllerTestController($dispatcher); } /** @@ -76,7 +66,7 @@ final class StudipControllerTest extends Codeception\Test\Unit } /** - * @dataProvider UrlForProvider + * @dataProvider RedirectProvider * @covers StudipController::redirect */ public function testRedirect(string $expected, ...$args): void @@ -106,7 +96,7 @@ final class StudipControllerTest extends Codeception\Test\Unit } /** - * @dataProvider UrlForProvider + * @dataProvider RedirectProvider * @covers StudipController::relocate */ public function testRelocate(string $expected, ...$args): void @@ -136,7 +126,7 @@ final class StudipControllerTest extends Codeception\Test\Unit } /** - * @dataProvider UrlForProvider + * @dataProvider RedirectProvider * @covers StudipController::relocate * @backupGlobals enabled */ @@ -187,6 +177,7 @@ final class StudipControllerTest extends Codeception\Test\Unit public function UrlForProvider(): array { return [ + '0-action' => ['dispatch.php/studip_controller_test/foo'], '1-action' => ['dispatch.php/foo', 'foo'], '1-action-and-parameter' => ['dispatch.php/foo?bar=42', 'foo', ['bar' => 42]], '1-action-and-parameters' => ['dispatch.php/foo?bar=42&baz=23', 'foo', ['bar' => 42, 'baz' => 23]], @@ -197,6 +188,13 @@ final class StudipControllerTest extends Codeception\Test\Unit ]; } + public function RedirectProvider(): array + { + $result = $this->UrlForProvider(); + unset($result['0-action']); + return $result; + } + public function absoluteUrlForProvider(): array { return [ @@ -214,3 +212,12 @@ final class StudipControllerTest extends Codeception\Test\Unit } } +class StudipControllerTestController extends StudipController +{ + public function __construct($dispatcher) + { + parent::__construct($dispatcher); + + $this->current_action = 'foo'; + } +} |
