Skip to content

Commit

Permalink
Fix styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Riimu committed Jun 29, 2018
1 parent 2a1b272 commit 7c37fb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/RouteDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ private function formatEncode(string $part): string
*/
private function isValidPattern(string $pattern): bool
{
$result = false;
set_error_handler(function (int $severity, string $message, string $file, int $line): bool {
throw new \ErrorException($message, 0, $severity, $file, $line);
}, \E_ALL);
Expand Down
2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function split_segments(string $path): array
*/
function string_split(string $pattern, string $subject): array
{
$parts = preg_split($pattern, $subject, -1, PREG_SPLIT_NO_EMPTY);
$parts = preg_split($pattern, $subject, -1, \PREG_SPLIT_NO_EMPTY);

if (!\is_array($parts) || preg_last_error() !== \PREG_NO_ERROR) {
throw new \RuntimeException('Error splitting string');
Expand Down
13 changes: 13 additions & 0 deletions tests/tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ public function testMixedStaticDynamicRoute()
$this->assertRoute($router, 'POST', '/path/to/route/', 'test.b', '/path/to/route/', ['param' => 'to']);
}

public function testStaticRoutePreference()
{
$router = $this->getRouter([
['test.a', 'GET', '/path/to/route/'],
['test.b', 'GET', '/path/{param}/route/'],
]);

$this->assertRoute($router, 'GET', '/path/to/route/', 'test.a', '/path/to/route/');
$this->assertRoute($router, 'GET', '/path/foobar/route/', 'test.b', '/path/foobar/route/', [
'param' => 'foobar'
]);
}

public function testRoutingWithEncodedCharacter()
{
$router = $this->getRouter([
Expand Down

0 comments on commit 7c37fb1

Please sign in to comment.