- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
98 lines
3.5 KiB
PHP
98 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\Http\Method;
|
|
use App\Framework\Router\ValueObjects\Placeholder;
|
|
use App\Framework\Router\ValueObjects\RoutePath;
|
|
|
|
describe('Route Attribute', function () {
|
|
describe('string path support', function () {
|
|
it('works with traditional string paths', function () {
|
|
$route = new Route(path: '/api/users/{id}', method: Method::GET);
|
|
|
|
expect($route->getPathAsString())->toBe('/api/users/{id}');
|
|
expect($route->getRoutePath()->toString())->toBe('/api/users/{id}');
|
|
expect($route->getRoutePath()->isDynamic())->toBeTrue();
|
|
});
|
|
|
|
it('handles static string paths', function () {
|
|
$route = new Route(path: '/health', method: Method::GET);
|
|
|
|
expect($route->getPathAsString())->toBe('/health');
|
|
expect($route->getRoutePath()->isStatic())->toBeTrue();
|
|
});
|
|
});
|
|
|
|
describe('RoutePath object support', function () {
|
|
it('works with RoutePath objects', function () {
|
|
$routePath = RoutePath::fromElements(
|
|
'api',
|
|
'images',
|
|
Placeholder::fromString('filename')
|
|
);
|
|
|
|
$route = new Route(path: $routePath, method: Method::GET);
|
|
|
|
expect($route->getPathAsString())->toBe('/api/images/{filename}');
|
|
expect($route->getRoutePath())->toBe($routePath);
|
|
});
|
|
|
|
it('handles complex RoutePath objects', function () {
|
|
$routePath = RoutePath::fromElements(
|
|
'api',
|
|
'users',
|
|
Placeholder::typed('userId', 'uuid'),
|
|
'posts',
|
|
Placeholder::typed('postId', 'int')
|
|
);
|
|
|
|
$route = new Route(path: $routePath, method: Method::POST);
|
|
|
|
expect($route->getPathAsString())->toBe('/api/users/{userId}/posts/{postId}');
|
|
expect($route->method)->toBe(Method::POST);
|
|
});
|
|
|
|
it('handles wildcard parameters', function () {
|
|
$routePath = RoutePath::fromElements(
|
|
'files',
|
|
Placeholder::wildcard('path')
|
|
);
|
|
|
|
$route = new Route(path: $routePath, method: Method::GET);
|
|
|
|
expect($route->getPathAsString())->toBe('/files/{path*}');
|
|
});
|
|
});
|
|
|
|
describe('mixed usage compatibility', function () {
|
|
it('provides consistent interface regardless of input type', function () {
|
|
$stringRoute = new Route(path: '/api/users/{id}', method: Method::GET);
|
|
$objectRoute = new Route(
|
|
path: RoutePath::fromElements('api', 'users', Placeholder::fromString('id')),
|
|
method: Method::GET
|
|
);
|
|
|
|
expect($stringRoute->getPathAsString())->toBe($objectRoute->getPathAsString());
|
|
expect($stringRoute->getRoutePath()->toString())->toBe($objectRoute->getRoutePath()->toString());
|
|
});
|
|
});
|
|
|
|
describe('route compilation', function () {
|
|
it('compiles to CompiledRoute correctly', function () {
|
|
$routePath = RoutePath::fromElements(
|
|
'api',
|
|
'users',
|
|
Placeholder::typed('id', 'int')
|
|
);
|
|
|
|
$route = new Route(path: $routePath, method: Method::GET, name: 'users.show');
|
|
|
|
// Note: This test would need CompiledRoute to be available
|
|
// For now, we just test the path conversion
|
|
expect($route->getPathAsString())->toBe('/api/users/{id}');
|
|
});
|
|
});
|
|
});
|