bab/tested-routes-checker-bundle
Installation:
composer require --dev bab/tested-routes-checker-bundle
Add to config/bundles.php:
Bab\TestedRoutesCheckerBundle\BabTestedRoutesCheckerBundle::class => ['dev' => true, 'test' => true],
First Run:
var/cache/bab_tested_routes_checker_bundle_route_storage.php bin/console bab:tested-routes-checker:check
Prevent Uncovered Routes in CI: Add this to your GitHub Actions workflow after tests:
- name: Check Tested Routes
run: php bin/console bab:tested-routes-checker:check
Test Execution:
--coverage-text or --coverage-clover to generate coverage reports alongside route tracking../vendor/bin/phpunit --coverage-text --colors=never
CI Pipeline:
var/cache/bab_tested_routes_checker_bundle_route_storage as an artifact, then merge and check in a final job (see README for details).Local Development:
php bin/console bab:tested-routes-checker:check --env=test to validate routes during local testing.Exclude Routes:
Create a .bab-trc-baseline file with one route per line (e.g., api/login) to ignore specific routes.
echo "api/login" > .bab-trc-baseline
Custom Cache Directory:
Override the cache path in config/packages/bab_tested_routes_checker.yaml:
bab_tested_routes_checker:
cache_dir: '%kernel.cache_dir%/custom_route_cache'
Symfony Localized Routes:
The bundle automatically handles localized routes (e.g., _locale=de). No extra configuration is needed.
Cache Clearing:
bab_tested_routes_checker_bundle_route_storage) is not cleared by default during cache:clear. Manually delete it or add it to your cache:pool cleanup script.config/packages/framework.yaml:
framework:
cache:
pools:
bab_route_checker:
path: '%kernel.cache_dir%/bab_tested_routes_checker_bundle_route_storage'
Test Environment:
test or dev environments (configured in bundles.php). Running it in prod will show no results.Route Matching:
app_homepage vs. app_home). Ensure your tests hit the correct route names.Parallel Tests:
--parallel), merge the cache files manually or use a shared storage solution.Verify Cache Contents: Inspect the cache file directly:
cat var/cache/bab_tested_routes_checker_bundle_route_storage
Expected format: One route name per line (e.g., app_homepage).
Check Route Names: List all routes to confirm names:
php bin/console debug:router
CI Debugging: Add a step to dump the cache before checking:
- name: Debug Cache
run: cat var/cache/bab_tested_routes_checker_bundle_route_storage
Custom Report Format:
Override the command class (Bab\TestedRoutesCheckerBundle\Command\CheckCommand) to extend the report (e.g., JSON output).
Route Filtering:
Extend the Bab\TestedRoutesCheckerBundle\Checker\RouteChecker service to add custom logic (e.g., ignore routes with specific parameters).
Event Listeners:
Listen to bab.tested_routes_checker.route_captured to log or process routes in real-time:
// config/services.yaml
services:
App\EventListener\RouteLogger:
tags:
- { name: kernel.event_listener, event: bab.tested_routes_checker.route_captured, method: onRouteCaptured }
How can I help you explore Laravel packages today?