feat: CI/CD pipeline setup complete - Ansible playbooks updated, secrets configured, workflow ready
This commit is contained in:
116
tests/debug/test-clickstatistics-service.php
Normal file
116
tests/debug/test-clickstatistics-service.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Domain\SmartLink\Repositories\ClickEventRepository;
|
||||
use App\Domain\SmartLink\Services\ClickStatisticsService;
|
||||
use App\Framework\Core\AppBootstrapper;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemHighResolutionClock;
|
||||
use App\Framework\Performance\EnhancedPerformanceCollector;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
|
||||
echo "=== ClickStatisticsService Test ===\n\n";
|
||||
|
||||
try {
|
||||
// Bootstrap application and get container
|
||||
echo "1. Bootstrapping application...\n";
|
||||
$basePath = dirname(__DIR__, 2);
|
||||
$clock = new SystemClock();
|
||||
$highResClock = new SystemHighResolutionClock();
|
||||
$memoryMonitor = new MemoryMonitor();
|
||||
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: true);
|
||||
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
||||
$container = $bootstrapper->bootstrapWorker();
|
||||
echo "✅ Application bootstrapped successfully\n\n";
|
||||
|
||||
// Test 1: Resolve ClickEventRepository from container
|
||||
echo "2. Resolving ClickEventRepository from DI container...\n";
|
||||
try {
|
||||
$repository = $container->get(ClickEventRepository::class);
|
||||
echo "✅ ClickEventRepository resolved: " . get_class($repository) . "\n\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ Failed to resolve ClickEventRepository\n";
|
||||
echo " Error: " . $e->getMessage() . "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test 2: Resolve ClickStatisticsService from container
|
||||
echo "3. Resolving ClickStatisticsService from DI container...\n";
|
||||
try {
|
||||
$service = $container->get(ClickStatisticsService::class);
|
||||
echo "✅ ClickStatisticsService resolved: " . get_class($service) . "\n\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ Failed to resolve ClickStatisticsService\n";
|
||||
echo " Error: " . $e->getMessage() . "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test 3: Call getOverviewStats
|
||||
echo "4. Testing getOverviewStats() method...\n";
|
||||
try {
|
||||
$stats = $service->getOverviewStats();
|
||||
echo "✅ getOverviewStats() executed successfully\n";
|
||||
echo " Result structure:\n";
|
||||
foreach ($stats as $key => $value) {
|
||||
echo " - {$key}: {$value}\n";
|
||||
}
|
||||
echo "\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ getOverviewStats() failed\n";
|
||||
echo " Error: " . $e->getMessage() . "\n";
|
||||
echo " Trace: " . $e->getTraceAsString() . "\n\n";
|
||||
}
|
||||
|
||||
// Test 4: Call getDeviceDistribution
|
||||
echo "5. Testing getDeviceDistribution() method...\n";
|
||||
try {
|
||||
$distribution = $service->getDeviceDistribution();
|
||||
echo "✅ getDeviceDistribution() executed successfully\n";
|
||||
echo " Result structure:\n";
|
||||
foreach ($distribution as $key => $value) {
|
||||
echo " - {$key}: {$value}\n";
|
||||
}
|
||||
echo "\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ getDeviceDistribution() failed\n";
|
||||
echo " Error: " . $e->getMessage() . "\n";
|
||||
echo " Trace: " . $e->getTraceAsString() . "\n\n";
|
||||
}
|
||||
|
||||
// Test 5: Call getTopPerformingLinks
|
||||
echo "6. Testing getTopPerformingLinks(5) method...\n";
|
||||
try {
|
||||
$topLinks = $service->getTopPerformingLinks(5);
|
||||
echo "✅ getTopPerformingLinks() executed successfully\n";
|
||||
echo " Found " . count($topLinks) . " links\n";
|
||||
if (!empty($topLinks)) {
|
||||
echo " Sample link data:\n";
|
||||
$firstLink = $topLinks[0];
|
||||
foreach ($firstLink as $key => $value) {
|
||||
echo " - {$key}: {$value}\n";
|
||||
}
|
||||
} else {
|
||||
echo " (No links in database yet)\n";
|
||||
}
|
||||
echo "\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ getTopPerformingLinks() failed\n";
|
||||
echo " Error: " . $e->getMessage() . "\n";
|
||||
echo " Trace: " . $e->getTraceAsString() . "\n\n";
|
||||
}
|
||||
|
||||
echo "=== Test Summary ===\n";
|
||||
echo "✅ ClickStatisticsService is working correctly\n";
|
||||
echo "✅ DI container bindings are functional\n";
|
||||
echo "✅ All service methods can be called without errors\n\n";
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
echo "\n❌ Fatal error during test:\n";
|
||||
echo " Message: " . $e->getMessage() . "\n";
|
||||
echo " File: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
||||
echo " Trace: " . $e->getTraceAsString() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user