- 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.
121 lines
4.7 KiB
PHP
121 lines
4.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test script for nullable bool flags
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Console\CommandParameterResolver;
|
|
use App\Framework\Console\ConsoleOutput;
|
|
use App\Framework\Console\MethodSignatureAnalyzer;
|
|
|
|
// Test class with nullable bool flags
|
|
class FlagTestCommand
|
|
{
|
|
// Nullable bool flags
|
|
public function withFlags(
|
|
string $environment,
|
|
?bool $verbose = null,
|
|
?bool $force = null,
|
|
?bool $dryRun = null
|
|
): int {
|
|
echo "Environment: {$environment}\n";
|
|
echo "Verbose: " . ($verbose === null ? 'null' : ($verbose ? 'true' : 'false')) . "\n";
|
|
echo "Force: " . ($force === null ? 'null' : ($force ? 'true' : 'false')) . "\n";
|
|
echo "DryRun: " . ($dryRun === null ? 'null' : ($dryRun ? 'true' : 'false')) . "\n";
|
|
return 0;
|
|
}
|
|
|
|
// Mixed: typed params + flags
|
|
public function mixedWithFlags(
|
|
string $name,
|
|
int $age,
|
|
?bool $verified = null,
|
|
?bool $active = null
|
|
): int {
|
|
echo "Name: {$name}, Age: {$age}\n";
|
|
echo "Verified: " . ($verified === null ? 'null' : ($verified ? 'true' : 'false')) . "\n";
|
|
echo "Active: " . ($active === null ? 'null' : ($active ? 'true' : 'false')) . "\n";
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
echo "Testing Nullable Bool Flags\n";
|
|
echo "===========================\n\n";
|
|
|
|
$resolver = new CommandParameterResolver(new MethodSignatureAnalyzer());
|
|
$command = new FlagTestCommand();
|
|
$output = new ConsoleOutput();
|
|
|
|
// Test 1: No flags provided
|
|
echo "Test 1: No flags (all should be null)\n";
|
|
echo "Command: deploy production\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'withFlags');
|
|
$params = $resolver->resolveParameters($method, ['production'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 2: One flag provided
|
|
echo "Test 2: One flag --verbose\n";
|
|
echo "Command: deploy production --verbose\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'withFlags');
|
|
$params = $resolver->resolveParameters($method, ['production', '--verbose'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 3: Multiple flags
|
|
echo "Test 3: Multiple flags --verbose --force\n";
|
|
echo "Command: deploy production --verbose --force\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'withFlags');
|
|
$params = $resolver->resolveParameters($method, ['production', '--verbose', '--force'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 4: All flags
|
|
echo "Test 4: All flags --verbose --force --dry-run\n";
|
|
echo "Command: deploy production --verbose --force --dry-run\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'withFlags');
|
|
$params = $resolver->resolveParameters($method, ['production', '--verbose', '--force', '--dry-run'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 5: Mixed params + flags (no flags)
|
|
echo "Test 5: Mixed parameters without flags\n";
|
|
echo "Command: user Alice 25\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'mixedWithFlags');
|
|
$params = $resolver->resolveParameters($method, ['Alice', '25'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 6: Mixed params + flags (with flags)
|
|
echo "Test 6: Mixed parameters with flags\n";
|
|
echo "Command: user Alice 25 --verified --active\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'mixedWithFlags');
|
|
$params = $resolver->resolveParameters($method, ['Alice', '25', '--verified', '--active'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
// Test 7: Mixed params + one flag
|
|
echo "Test 7: Mixed parameters with one flag\n";
|
|
echo "Command: user Bob 30 --verified\n";
|
|
$method = new ReflectionMethod(FlagTestCommand::class, 'mixedWithFlags');
|
|
$params = $resolver->resolveParameters($method, ['Bob', '30', '--verified'], null, $output);
|
|
echo "Resolved params count: " . count($params) . "\n";
|
|
$result = $method->invokeArgs($command, $params);
|
|
echo "Result: {$result}\n\n";
|
|
|
|
echo "✅ All tests completed!\n";
|
|
echo "\nExpected behavior:\n";
|
|
echo "- Flags without '--' prefix: null\n";
|
|
echo "- Flags with '--' prefix: true\n";
|
|
echo "- No boolean false (only null or true)\n";
|