- 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.
90 lines
3.1 KiB
PHP
90 lines
3.1 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\StreamingPlatform;
|
|
use App\Domain\PreSave\ValueObjects\TrackUrl;
|
|
use App\Framework\Core\ValueObjects\Timestamp;
|
|
use App\Framework\Database\PdoConnection;
|
|
use App\Framework\OAuth\Storage\OAuthTokenRepository;
|
|
|
|
echo "=== Simple Pre-Save System Test ===" . PHP_EOL . PHP_EOL;
|
|
|
|
// Create MySQL database connection
|
|
$pdo = new PDO(
|
|
'mysql:host=db;dbname=michaelschiemer;charset=utf8mb4',
|
|
'mdb-user',
|
|
'StartSimple2024!'
|
|
);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
|
|
|
$connection = new PdoConnection($pdo);
|
|
|
|
// Create repositories
|
|
$campaignRepo = new PreSaveCampaignRepository($connection);
|
|
$registrationRepo = new PreSaveRegistrationRepository($connection);
|
|
$tokenRepo = new OAuthTokenRepository($connection);
|
|
|
|
echo "✓ Database connected and repositories created" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 1: Create campaign
|
|
echo "Test 1: Creating campaign..." . PHP_EOL;
|
|
$campaign = PreSaveCampaign::create(
|
|
title: 'Test Album',
|
|
artistName: 'Test Artist',
|
|
coverImageUrl: 'https://example.com/cover.jpg',
|
|
releaseDate: Timestamp::fromFloat(time() + (7 * 24 * 60 * 60)),
|
|
trackUrls: [
|
|
TrackUrl::create(StreamingPlatform::SPOTIFY, '3n3Ppam7vgaVa1iaRUc9Lp'),
|
|
],
|
|
description: 'Test description',
|
|
startDate: Timestamp::now()
|
|
);
|
|
|
|
$savedCampaign = $campaignRepo->save($campaign);
|
|
echo "✓ Campaign created with ID: {$savedCampaign->id}" . PHP_EOL . PHP_EOL;
|
|
$campaign = $savedCampaign;
|
|
|
|
// Test 2: Create registration
|
|
echo "Test 2: Creating registration..." . PHP_EOL;
|
|
$registration = PreSaveRegistration::create(
|
|
campaignId: $campaign->id,
|
|
userId: 'test_user',
|
|
platform: StreamingPlatform::SPOTIFY
|
|
);
|
|
|
|
$savedRegistration = $registrationRepo->save($registration);
|
|
$registration = $savedRegistration;
|
|
echo "✓ Registration created with ID: {$registration->id}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 3: Find registrations
|
|
echo "Test 3: Finding registrations..." . PHP_EOL;
|
|
$found = $registrationRepo->findByCampaign($campaign->id);
|
|
echo "✓ Found " . count($found) . " registration(s)" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 4: Publish campaign
|
|
echo "Test 4: Publishing campaign..." . PHP_EOL;
|
|
$publishedCampaign = $campaign->publish();
|
|
$campaignRepo->save($publishedCampaign);
|
|
echo "✓ Campaign status: {$publishedCampaign->status->value}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 5: Process registration (mark as completed)
|
|
echo "Test 5: Processing registration..." . PHP_EOL;
|
|
$processed = $registration->markAsCompleted();
|
|
$registrationRepo->save($processed);
|
|
echo "✓ Registration status: {$processed->status->value}" . PHP_EOL . PHP_EOL;
|
|
|
|
// Cleanup
|
|
echo "Cleanup..." . PHP_EOL;
|
|
$campaignRepo->delete($campaign->id);
|
|
echo "✓ Campaign deleted" . PHP_EOL . PHP_EOL;
|
|
|
|
echo "=== All tests passed! ===" . PHP_EOL;
|