Skip to content

Commit 03f091a

Browse files
committed
Added a unit test for a potential bug.
1 parent 28ceeb0 commit 03f091a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/RouteMatcherTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,24 @@ public function testMatchThrowsIfRoutePathHasDuplicateParameters()
119119

120120
$this->testMatcher->match("GET", "/foo/bar/baz", [ $route ]);
121121
}
122+
123+
public function testMatchDoesNotMatchPartialMatches()
124+
{
125+
// Create route for individual entity
126+
$route1 = new Route("foo", "/bar/{param}");
127+
$route1
128+
->target("GET", "FooController::getAction")
129+
->target("DELETE", "FooController::deleteAction")
130+
;
131+
132+
// Create route for collection of same entities
133+
$route2 = new Route("foo_collection", "/bar");
134+
$route2
135+
->target("GET", "FooController::getCollectionAction")
136+
->target("POST", "FooController::postAction")
137+
;
138+
139+
// Pass a URL where the start ("/bar") would match the route (check against partial match)
140+
$this->assertNull($this->testMatcher->match("POST", "/bar/53", [ $route1, $route2 ]));
141+
}
122142
}

0 commit comments

Comments
 (0)