Custom regex fix

- Fixed issue with custom-regex maching both host-name and url (issue: #503).
- Changed TestRouter so host-name is always set.
This commit is contained in:
Simon Sessingø
2021-03-22 14:09:27 +01:00
parent d2b3ea4f54
commit 8a0f30c05e
3 changed files with 18 additions and 1 deletions
@@ -171,4 +171,16 @@ class RouterUrlTest extends \PHPUnit\Framework\TestCase
}
public function testCustomRegex()
{
TestRouter::request()->setHost('google.com');
TestRouter::get('/admin/', function() {
return 'match';
})->setMatch('/^\/admin\/?(.*)/i');
$output = TestRouter::debugOutput('/admin/asd/bec/123', 'get');
$this->assertEquals('match', $output);
}
}
+5
View File
@@ -3,6 +3,11 @@
class TestRouter extends \Pecee\SimpleRouter\SimpleRouter
{
public function __construct()
{
static::request()->setHost('testhost.com');
}
public static function debugNoReset($testUrl, $testMethod = 'get')
{
$request = static::request();