diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2024-05-03 14:06:50 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2024-05-03 14:06:50 +0000 |
| commit | a54b6f395dbef03e679357e9e93891d4b4749ba1 (patch) | |
| tree | 71e6a004fb4924add05ec0ff6ac911d8b9209d1f /tests | |
| parent | d066e3494ba0b661d149dcd7bb267aed8f4e65ea (diff) | |
functions.php: added studip_interpolate, closes #3555
Closes #3555
Merge request studip/studip!2442
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/lib/FunctionsTest.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/lib/FunctionsTest.php b/tests/unit/lib/FunctionsTest.php index 9a92f1a..670d00c 100644 --- a/tests/unit/lib/FunctionsTest.php +++ b/tests/unit/lib/FunctionsTest.php @@ -80,11 +80,29 @@ class FunctionsTest extends \Codeception\Test\Unit public function testTrailsControllerExtractActionAndArgs() { $controller = new Trails_Controller(null); - list($action, $args, $format) = $controller->extract_action_and_args('foo/bar//42.html'); + [$action, $args, $format] = $controller->extract_action_and_args('foo/bar//42.html'); $this->assertEquals('foo', $action); $this->assertEquals(['bar', '', '42'], $args); $this->assertEquals('html', $format); } + + /** + * @covers ::studip_interpolate + */ + public function testStudipInterpolate() + { + $this->assertEquals( + '12bar34', + studip_interpolate('12%{foo}34', ['foo' => 'bar']) + ); + $this->assertEquals( + 'foo', + studip_interpolate('%{ bar }', ['bar' => 'foo']) + ); + + $this->expectException(Exception::class); + studip_interpolate('%{foo}', []); + } } |
