test(Router): fix broken error test and add functional coverage for match/generate#3
Merged
Merged
Conversation
… broken error handling test Agent-Logs-Url: https://github.com/floatphp/Classes/sessions/8a62077b-df55-4dd8-a997-51f7f178f70d Co-authored-by: Jakiboy <7604550+Jakiboy@users.noreply.github.com>
Agent-Logs-Url: https://github.com/floatphp/Classes/sessions/8a62077b-df55-4dd8-a997-51f7f178f70d Co-authored-by: Jakiboy <7604550+Jakiboy@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Jakiboy
April 22, 2026 09:32
View session
There was a problem hiding this comment.
Pull request overview
Updates RouterTest to fix invalid error-handling coverage and add functional tests for the router’s core behaviors (URL matching + URL generation), along with previously untested accessors/state methods.
Changes:
- Replace the broken
addRoutes()error-handling test (which triggered a PHPTypeErrorinstead ofRouterException) with exception tests that exercise realRouterExceptioncode paths inmap()/generate(). - Add functional coverage for
match()across static/param routes, method filtering, wildcards, regex routes, query stripping, base-path handling, and permission propagation. - Add functional coverage for
generate()(static + param substitution + base path), plus tests forgetBase(),getTypes(),getNames(),hasRoute(),clearRoutes(),addTypes(),addRoutes(), andgetRoutes()behaviors.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RouterTesthad a broken error-handling test and no coverage of the router's two core behaviours: URL matching and URL generation.Bug fix
testRouterErrorHandlingpassed astringtoaddRoutes(array $routes). PHP's type system throwsTypeErrorbefore the method body runs —RouterExceptionis never reached. Replaced with five tests that triggerRouterExceptionthrough code paths that actually throw it:map()with empty method or routemap()with a duplicate named routegenerate()with an empty name or a non-existent route nameFunctional coverage added
match()*)*), regex (@) prefix routespermissionfield propagationgenerate()Accessor / state methods
getBase(),getTypes(),getNames(),hasRoute(),clearRoutes(),addTypes(),addRoutes()— all previously untested