Fixed parameter default-value being overwritten (issue: #347).

This commit is contained in:
Simon Sessingo
2018-01-06 03:27:27 +01:00
parent f2d106c649
commit 4d2b584936
2 changed files with 26 additions and 14 deletions
+14
View File
@@ -125,6 +125,20 @@ class RouterRouteTest extends PHPUnit_Framework_TestCase
TestRouter::debug('/my/custom-path', 'get');
}
public function testParameterDefaultValue() {
$defaultVariable = null;
TestRouter::get('/my/{path?}', function($path = 'working') use(&$defaultVariable) {
$defaultVariable = $path;
});
TestRouter::debug('/my/');
$this->assertEquals('working', $defaultVariable);
}
public function testDefaultParameterRegex()
{
TestRouter::get('/my/{path}', 'DummyController@param', ['defaultParameterRegex' => '[\w\-]+']);