- 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.
103 lines
3.8 KiB
PHP
103 lines
3.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Domain\PreSave\PreSaveCampaign;
|
|
use App\Domain\PreSave\PreSaveCampaignRepository;
|
|
use App\Domain\PreSave\PreSaveRegistration;
|
|
use App\Domain\PreSave\PreSaveRegistrationRepository;
|
|
use App\Domain\PreSave\ValueObjects\CampaignStatus;
|
|
use App\Domain\PreSave\ValueObjects\Platform;
|
|
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 "=== Pre-Save Campaign System Test ===" . PHP_EOL . PHP_EOL;
|
|
|
|
// Bootstrap application
|
|
$basePath = dirname(__DIR__, 2);
|
|
$clock = new SystemClock();
|
|
$highResClock = new SystemHighResolutionClock();
|
|
$memoryMonitor = new MemoryMonitor();
|
|
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
|
|
|
|
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
|
$app = $bootstrapper->bootstrapWeb();
|
|
$container = $app->getContainer();
|
|
|
|
// Get repositories
|
|
$campaignRepo = $container->get(PreSaveCampaignRepository::class);
|
|
$registrationRepo = $container->get(PreSaveRegistrationRepository::class);
|
|
|
|
// Test 1: Create a campaign
|
|
echo "Test 1: Creating a Pre-Save Campaign..." . PHP_EOL;
|
|
|
|
$campaign = PreSaveCampaign::create(
|
|
title: 'Summer Vibes Album',
|
|
artistName: 'The Cool Artists',
|
|
coverImageUrl: 'https://example.com/cover.jpg',
|
|
description: 'An amazing summer album with 12 tracks',
|
|
releaseDate: time() + (7 * 24 * 60 * 60), // Release in 7 days
|
|
trackUrls: [
|
|
'spotify' => 'https://open.spotify.com/album/xyz',
|
|
'apple_music' => 'https://music.apple.com/album/xyz',
|
|
'tidal' => 'https://tidal.com/album/xyz',
|
|
],
|
|
startDate: time() // Start now
|
|
);
|
|
|
|
$campaignRepo->save($campaign);
|
|
echo "✓ Campaign created with ID: {$campaign->id}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 2: Create a registration
|
|
echo "Test 2: Creating a Pre-Save Registration..." . PHP_EOL;
|
|
|
|
$registration = PreSaveRegistration::create(
|
|
campaignId: $campaign->id,
|
|
userId: 'user123',
|
|
platform: Platform::SPOTIFY,
|
|
registeredAt: time()
|
|
);
|
|
|
|
$registrationRepo->save($registration);
|
|
echo "✓ Registration created with ID: {$registration->id}" . PHP_EOL;
|
|
echo " - User: {$registration->userId}" . PHP_EOL;
|
|
echo " - Platform: {$registration->platform->value}" . PHP_EOL;
|
|
echo " - Status: {$registration->status->value}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 3: Find registrations by campaign
|
|
echo "Test 3: Finding registrations for campaign..." . PHP_EOL;
|
|
|
|
$registrations = $registrationRepo->findByCampaign($campaign->id);
|
|
echo "✓ Found " . count($registrations) . " registration(s)" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 4: Update campaign status
|
|
echo "Test 4: Updating campaign status..." . PHP_EOL;
|
|
|
|
$campaign = $campaign->updateStatus(CampaignStatus::ACTIVE);
|
|
$campaignRepo->save($campaign);
|
|
echo "✓ Campaign status updated to: {$campaign->status->value}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 5: Process registration
|
|
echo "Test 5: Processing registration..." . PHP_EOL;
|
|
|
|
$registration = $registration->process(time());
|
|
$registrationRepo->save($registration);
|
|
echo "✓ Registration processed" . PHP_EOL;
|
|
echo " - New status: {$registration->status->value}" . PHP_EOL;
|
|
echo " - Processed at: " . date('Y-m-d H:i:s', $registration->processedAt ?? time()) . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 6: Foreign key cascade delete
|
|
echo "Test 6: Testing foreign key cascade delete..." . PHP_EOL;
|
|
|
|
$campaignRepo->delete($campaign->id);
|
|
$registrationsAfterDelete = $registrationRepo->findByCampaign($campaign->id);
|
|
echo "✓ Campaign deleted" . PHP_EOL;
|
|
echo "✓ Registrations after delete: " . count($registrationsAfterDelete) . " (should be 0 due to CASCADE)" . PHP_EOL . PHP_EOL;
|
|
|
|
echo "=== All tests completed successfully! ===" . PHP_EOL;
|