Files
michaelschiemer/tests/debug/test-database-platform.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

80 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Config\Environment;
use App\Framework\Database\Platform\DatabasePlatformInitializer;
use App\Framework\Database\Platform\MySQLPlatform;
use App\Framework\Database\Platform\ValueObjects\ColumnDefinition;
use App\Framework\Database\Platform\ValueObjects\TableOptions;
echo "=== Database Platform Test ===\n\n";
// Test 1: Environment setup
echo "1. Testing Environment setup...\n";
$env = new Environment();
$dbDriver = $env->get('DB_DRIVER', 'mysql');
echo " DB_DRIVER: {$dbDriver}\n";
// Test 2: Platform Initializer
echo "\n2. Testing DatabasePlatformInitializer...\n";
$initializer = new DatabasePlatformInitializer($env);
$platform = $initializer->__invoke();
echo " Platform: " . $platform->getName() . "\n";
// Test 3: MySQL Platform
echo "\n3. Testing MySQLPlatform...\n";
$mysqlPlatform = new MySQLPlatform();
echo " Platform name: " . $mysqlPlatform->getName() . "\n";
echo " Supports JSON: " . ($mysqlPlatform->supportsFeature('json_columns') ? 'Yes' : 'No') . "\n";
// Test 4: Column Definition
echo "\n4. Testing Column Definitions...\n";
$idColumn = ColumnDefinition::id();
echo " ID column: " . $idColumn->name . " (" . $idColumn->type->value . ")\n";
echo " Is Primary Key: " . ($idColumn->isPrimaryKey() ? 'Yes' : 'No') . "\n";
$stringColumn = ColumnDefinition::string('name', 255, false);
echo " String column: " . $stringColumn->name . " (" . $stringColumn->type->value . ")\n";
// Test 5: SQL Generation
echo "\n5. Testing SQL Generation...\n";
$columns = [
ColumnDefinition::id(),
ColumnDefinition::string('name', 255, false),
ColumnDefinition::text('description'),
ColumnDefinition::timestamp('created_at', false),
];
$options = TableOptions::default()->withComment('Test table');
try {
$sql = $mysqlPlatform->getCreateTableSQL('test_users', $columns, $options);
echo " CREATE TABLE SQL:\n";
echo " " . $sql . "\n";
} catch (\Throwable $e) {
echo " ERROR: " . $e->getMessage() . "\n";
}
// Test 6: Column Type SQL
echo "\n6. Testing Column Type SQL...\n";
$tests = [
['varchar', ['length' => 255]],
['integer', ['unsigned' => true]],
['text', []],
['timestamp', []],
];
foreach ($tests as [$type, $options]) {
try {
$typeSQL = $mysqlPlatform->getColumnTypeSQL($type, $options);
echo " {$type}: {$typeSQL}\n";
} catch (\Throwable $e) {
echo " {$type}: ERROR - " . $e->getMessage() . "\n";
}
}
echo "\n=== Test completed ===\n";