- 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.
124 lines
4.2 KiB
PHP
124 lines
4.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test script for optional ConsoleInput/ConsoleOutput parameters
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Console\CommandParameterResolver;
|
|
use App\Framework\Console\ConsoleInput;
|
|
use App\Framework\Console\ConsoleOutput;
|
|
use App\Framework\Console\MethodSignatureAnalyzer;
|
|
|
|
// Test class with various parameter combinations
|
|
class TestCommand
|
|
{
|
|
// No parameters
|
|
public function noParams(): int
|
|
{
|
|
echo "No parameters\n";
|
|
return 0;
|
|
}
|
|
|
|
// Only user parameters
|
|
public function userParamsOnly(string $name, int $age = 18): int
|
|
{
|
|
echo "Name: {$name}, Age: {$age}\n";
|
|
return 0;
|
|
}
|
|
|
|
// Only ConsoleOutput
|
|
public function outputOnly(ConsoleOutput $output, string $message = 'Hello'): int
|
|
{
|
|
$output->writeLine("Message: {$message}");
|
|
return 0;
|
|
}
|
|
|
|
// ConsoleInput and ConsoleOutput
|
|
public function bothConsoleParams(ConsoleInput $input, ConsoleOutput $output): int
|
|
{
|
|
$output->writeLine("Args: " . json_encode($input->getArguments()));
|
|
return 0;
|
|
}
|
|
|
|
// Mixed: Output, user param, user param with default
|
|
public function mixed(ConsoleOutput $output, string $name, int $count = 3): int
|
|
{
|
|
$output->writeLine("Name: {$name}, Count: {$count}");
|
|
return 0;
|
|
}
|
|
|
|
// All types mixed
|
|
public function allMixed(
|
|
ConsoleInput $input,
|
|
string $operation,
|
|
ConsoleOutput $output,
|
|
int $iterations = 1
|
|
): int {
|
|
$output->writeLine("Operation: {$operation}, Iterations: {$iterations}");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
echo "Testing optional ConsoleInput/ConsoleOutput parameters\n";
|
|
echo "=====================================================\n\n";
|
|
|
|
$resolver = new CommandParameterResolver(new MethodSignatureAnalyzer());
|
|
$command = new TestCommand();
|
|
$output = new ConsoleOutput();
|
|
|
|
// Test 1: No parameters
|
|
echo "Test 1: No parameters\n";
|
|
$method = new ReflectionMethod(TestCommand::class, 'noParams');
|
|
$params = $resolver->resolveParameters($method, [], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 2: Only user parameters
|
|
echo "Test 2: Only user parameters (name: 'John')\n";
|
|
$method = new ReflectionMethod(TestCommand::class, 'userParamsOnly');
|
|
$params = $resolver->resolveParameters($method, ['John'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 3: ConsoleOutput + user param
|
|
echo "Test 3: ConsoleOutput + user param (message: 'Custom')\n";
|
|
$method = new ReflectionMethod(TestCommand::class, 'outputOnly');
|
|
$params = $resolver->resolveParameters($method, ['Custom'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 4: Both ConsoleInput and ConsoleOutput
|
|
echo "Test 4: Both ConsoleInput and ConsoleOutput\n";
|
|
$input = new ConsoleInput(['arg1', 'arg2'], $output);
|
|
$method = new ReflectionMethod(TestCommand::class, 'bothConsoleParams');
|
|
$params = $resolver->resolveParameters($method, [], $input, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 5: Mixed parameters
|
|
echo "Test 5: Mixed parameters (name: 'Alice', count: 5)\n";
|
|
$method = new ReflectionMethod(TestCommand::class, 'mixed');
|
|
$params = $resolver->resolveParameters($method, ['Alice', '5'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 6: All types mixed
|
|
echo "Test 6: All types mixed (operation: 'process', iterations: 10)\n";
|
|
$input = new ConsoleInput(['process', '10'], $output);
|
|
$method = new ReflectionMethod(TestCommand::class, 'allMixed');
|
|
$params = $resolver->resolveParameters($method, ['process', '10'], $input, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
echo "✅ All tests completed successfully!\n";
|