Files
michaelschiemer/tests/Framework/Router/ParameterProcessorDebugTest.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

87 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Framework\DI\DefaultContainer;
use App\Framework\Http\ControllerRequestFactory;
use App\Framework\Logging\DefaultLogger;
use App\Framework\Reflection\ReflectionProvider;
use App\Framework\Router\ParameterProcessor;
describe('ParameterProcessor Debug', function () {
test('debug parameter processing for filename parameter', function () {
// Mock dependencies
$container = $this->createMock(DefaultContainer::class);
$requestFactory = $this->createMock(ControllerRequestFactory::class);
$logger = $this->createMock(DefaultLogger::class);
$reflectionProvider = $this->createMock(ReflectionProvider::class);
$processor = new ParameterProcessor($container, $requestFactory, $logger, $reflectionProvider);
// Simulate the parameter data that would come from UnifiedRouteVisitor
$params = [
[
'name' => 'filename',
'type' => 'string',
'isBuiltin' => true,
'hasDefault' => false,
'default' => null,
'isOptional' => false,
'attributes' => [],
],
];
// Simulate the query params that would come from DynamicRoute->paramValues
$queryParams = [
'filename' => 'test-image.jpg',
];
// Erwartung: filename sollte 'test-image.jpg' sein, nicht null
$result = $processor->prepareParameters($params, $queryParams);
expect($result)->toHaveCount(1);
expect($result[0])->toBe('test-image.jpg');
expect($result[0])->not->toBeNull();
});
test('debug parameter processing when parameter name missing from queryParams', function () {
$container = $this->createMock(DefaultContainer::class);
$requestFactory = $this->createMock(ControllerRequestFactory::class);
$logger = $this->createMock(DefaultLogger::class);
$reflectionProvider = $this->createMock(ReflectionProvider::class);
$processor = new ParameterProcessor($container, $requestFactory, $logger, $reflectionProvider);
$params = [
[
'name' => 'filename',
'type' => 'string',
'isBuiltin' => true,
'hasDefault' => false,
'default' => null,
'isOptional' => false,
'attributes' => [],
],
];
// Empty queryParams - das ist wahrscheinlich unser Problem
$queryParams = [];
// Das wird null zurückgeben - das ist der Bug!
$result = $processor->prepareParameters($params, $queryParams);
expect($result)->toHaveCount(1);
expect($result[0])->toBeNull(); // Das ist der aktuelle Bug
// Debug: Show what's happening
error_log('Parameter processing with empty queryParams - result: ' . json_encode($result));
});
test('debug how DynamicRoute paramValues should be populated', function () {
// Test wie paramValues in DynamicRoute gesetzt werden sollten
// Das sollte von HttpRouter oder RouteDispatcher gemacht werden
expect(true)->toBeTrue(); // Placeholder test
});
});