Skip to content

test(Router): fix broken error test and add functional coverage for match/generate#3

Merged
Jakiboy merged 2 commits into
masterfrom
copilot/check-router-class
Apr 22, 2026
Merged

test(Router): fix broken error test and add functional coverage for match/generate#3
Jakiboy merged 2 commits into
masterfrom
copilot/check-router-class

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

RouterTest had a broken error-handling test and no coverage of the router's two core behaviours: URL matching and URL generation.

Bug fix

testRouterErrorHandling passed a string to addRoutes(array $routes). PHP's type system throws TypeError before the method body runs — RouterException is never reached. Replaced with five tests that trigger RouterException through code paths that actually throw it:

  • map() with empty method or route
  • map() with a duplicate named route
  • generate() with an empty name or a non-existent route name

Functional coverage added

match()

  • Static routes, integer/alphanumeric/multiple params
  • Method filtering (single, pipe-separated, wildcard *)
  • Wildcard route (*), regex (@) prefix routes
  • Query-string stripping, base-path stripping, case-insensitive method
  • permission field propagation

generate()

  • Static route, single param, multiple params, with base path prepended

Accessor / state methods

  • getBase(), getTypes(), getNames(), hasRoute(), clearRoutes(), addTypes(), addRoutes() — all previously untested

Copilot AI and others added 2 commits April 22, 2026 09:30
@Jakiboy Jakiboy requested a review from Copilot April 22, 2026 09:33
@Jakiboy Jakiboy marked this pull request as ready for review April 22, 2026 09:33
@Jakiboy Jakiboy merged commit d1e0560 into master Apr 22, 2026
2 checks passed
@Jakiboy Jakiboy deleted the copilot/check-router-class branch April 22, 2026 09:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PHP TypeError instead of RouterException) with exception tests that exercise real RouterException code paths in map()/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 for getBase(), getTypes(), getNames(), hasRoute(), clearRoutes(), addTypes(), addRoutes(), and getRoutes() behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants