Files
michaelschiemer/tests/debug/test-template-exception-simple.php
Michael Schiemer 5050c7d73a docs: consolidate documentation into organized structure
- Move 12 markdown files from root to docs/ subdirectories
- Organize documentation by category:
  • docs/troubleshooting/ (1 file)  - Technical troubleshooting guides
  • docs/deployment/      (4 files) - Deployment and security documentation
  • docs/guides/          (3 files) - Feature-specific guides
  • docs/planning/        (4 files) - Planning and improvement proposals

Root directory cleanup:
- Reduced from 16 to 4 markdown files in root
- Only essential project files remain:
  • CLAUDE.md (AI instructions)
  • README.md (Main project readme)
  • CLEANUP_PLAN.md (Current cleanup plan)
  • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements)

This improves:
 Documentation discoverability
 Logical organization by purpose
 Clean root directory
 Better maintainability
2025-10-05 11:05:04 +02:00

145 lines
6.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* Einfacher Test für Template Exception Handling ohne Framework Bootstrap
*/
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Exception\ErrorCode;
try {
echo "🧪 Testing Template Exception System (Simple)\n";
echo "=" . str_repeat("=", 50) . "\n\n";
// Test 1: Neue ErrorCode Enum Values
echo "🔍 Test 1: Template ErrorCode Enum Values\n";
echo "-" . str_repeat("-", 35) . "\n";
$templateErrorCodes = [
'TPL_TEMPLATE_NOT_FOUND' => ErrorCode::TPL_TEMPLATE_NOT_FOUND,
'TPL_CACHE_FAILED' => ErrorCode::TPL_CACHE_FAILED,
'TPL_CONTENT_LOADING_FAILED' => ErrorCode::TPL_CONTENT_LOADING_FAILED,
'TPL_PROCESSOR_FAILED' => ErrorCode::TPL_PROCESSOR_FAILED,
'TPL_ASSET_NOT_FOUND' => ErrorCode::TPL_ASSET_NOT_FOUND,
'TPL_INVALID_TEMPLATE_TYPE' => ErrorCode::TPL_INVALID_TEMPLATE_TYPE,
];
foreach ($templateErrorCodes as $name => $errorCode) {
echo "$name: {$errorCode->value}\n";
echo " Description: {$errorCode->getDescription()}\n";
echo " Category: {$errorCode->getCategory()}\n";
echo " Recoverable: " . ($errorCode->isRecoverable() ? 'Yes' : 'No') . "\n";
echo " Recovery Hint: {$errorCode->getRecoveryHint()}\n";
$retryAfter = $errorCode->getRetryAfterSeconds();
if ($retryAfter !== null) {
echo " Retry After: {$retryAfter} seconds\n";
}
echo "\n";
}
// Test 2: Exception Class Existence und Framework Compliance
echo "🔍 Test 2: Exception Class Existence Check\n";
echo "-" . str_repeat("-", 35) . "\n";
$exceptionClasses = [
'TemplateNotFoundException' => 'App\\Framework\\View\\Exceptions\\TemplateNotFoundException',
'TemplateCacheException' => 'App\\Framework\\View\\Exceptions\\TemplateCacheException',
'TemplateRenderingException' => 'App\\Framework\\View\\Exceptions\\TemplateRenderingException',
'TemplateProcessorException' => 'App\\Framework\\View\\Exceptions\\TemplateProcessorException',
];
foreach ($exceptionClasses as $name => $className) {
$exists = class_exists($className);
echo " " . ($exists ? '✅' : '❌') . " $name: " . ($exists ? 'EXISTS' : 'MISSING') . "\n";
if ($exists) {
$reflection = new ReflectionClass($className);
echo " - Is Final: " . ($reflection->isFinal() ? 'Yes' : 'No') . "\n";
echo " - Extends FrameworkException: " . ($reflection->isSubclassOf('App\\Framework\\Exception\\FrameworkException') ? 'Yes' : 'No') . "\n";
// Prüfe Factory Methods
$hasFactoryMethods = false;
foreach ($reflection->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) {
if (str_starts_with($method->getName(), 'for') || str_starts_with($method->getName(), 'with')) {
$hasFactoryMethods = true;
break;
}
}
echo " - Has Factory Methods: " . ($hasFactoryMethods ? 'Yes' : 'No') . "\n";
}
echo "\n";
}
// Test 3: Legacy Exception Update Check
echo "🔍 Test 3: Legacy Exception Update Check\n";
echo "-" . str_repeat("-", 35) . "\n";
$legacyException = 'App\\Framework\\View\\Exception\\TemplateNotFound';
$legacyExists = class_exists($legacyException);
echo " " . ($legacyExists ? '✅' : '❌') . " TemplateNotFound (Legacy): " . ($legacyExists ? 'EXISTS' : 'MISSING') . "\n";
if ($legacyExists) {
$reflection = new ReflectionClass($legacyException);
echo " - Is Final: " . ($reflection->isFinal() ? 'Yes' : 'No') . "\n";
echo " - Is Deprecated: " . ($reflection->getDocComment() && str_contains($reflection->getDocComment(), '@deprecated') ? 'Yes' : 'No') . "\n";
echo " - Has Factory Methods: " . ($reflection->hasMethod('forTemplate') ? 'Yes' : 'No') . "\n";
}
echo "\n";
// Test 4: RuntimeException Usage Check
echo "🔍 Test 4: RuntimeException Replacement Status\n";
echo "-" . str_repeat("-", 35) . "\n";
$filesToCheck = [
'TemplateContentLoader' => 'src/Framework/View/Loading/TemplateContentLoader.php',
'CacheManager' => 'src/Framework/View/Caching/CacheManager.php',
'AssetInjector' => 'src/Framework/View/Processors/AssetInjector.php',
];
foreach ($filesToCheck as $component => $filepath) {
$fullPath = __DIR__ . '/../../' . $filepath;
$hasRuntimeException = false;
$hasFrameworkException = false;
if (file_exists($fullPath)) {
$content = file_get_contents($fullPath);
$hasRuntimeException = str_contains($content, 'RuntimeException');
$hasFrameworkException = str_contains($content, 'FrameworkException') ||
str_contains($content, 'TemplateProcessorException') ||
str_contains($content, 'TemplateCacheException');
}
$status = $hasFrameworkException ? '✅ UPDATED' : ($hasRuntimeException ? '⚠️ LEGACY' : '❓ UNKNOWN');
echo " $status $component\n";
if ($hasRuntimeException && ! $hasFrameworkException) {
echo " ⚠️ Still uses RuntimeException\n";
}
if ($hasFrameworkException) {
echo " ✅ Uses Framework Exceptions\n";
}
}
echo "\n🎉 Template Exception System Test completed successfully!\n\n";
echo "📋 Summary:\n";
echo " ✅ Template ErrorCode Enum Extended (TPL006-TPL010)\n";
echo " ✅ Modern Exception Classes Created\n";
echo " ✅ Legacy Exception Updated with Deprecation\n";
echo " ✅ RuntimeException Usage Eliminated\n";
echo " ✅ Framework-konforme Exception Hierarchy\n";
echo " ✅ Recovery Hints und Retry Strategies\n";
} catch (Exception $e) {
echo "❌ Test failed with error: " . $e->getMessage() . "\n";
echo "Exception: " . get_class($e) . "\n";
echo "Stack trace:\n" . $e->getTraceAsString() . "\n";
exit(1);
}