Files
michaelschiemer/tests/Framework/MagicLinks/ValueObjects/MagicLinkPayloadTest.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- 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.
2025-10-25 19:18:37 +02:00

64 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Framework\MagicLinks\ValueObjects\MagicLinkPayload;
describe('MagicLinkPayload', function () {
it('creates payload from array', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com', 'user_id' => 123]);
expect($payload->toArray())->toBe(['email' => 'test@example.com', 'user_id' => 123]);
});
it('throws exception for empty payload', function () {
expect(fn () => MagicLinkPayload::fromArray([]))
->toThrow(InvalidArgumentException::class, 'Payload cannot be empty');
});
it('retrieves value with get method', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com']);
expect($payload->get('email'))->toBe('test@example.com');
expect($payload->get('missing', 'default'))->toBe('default');
});
it('checks if key exists', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com']);
expect($payload->has('email'))->toBeTrue();
expect($payload->has('missing'))->toBeFalse();
});
it('creates new instance with added value', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com']);
$updated = $payload->with('user_id', 123);
expect($payload->has('user_id'))->toBeFalse();
expect($updated->has('user_id'))->toBeTrue();
expect($updated->get('user_id'))->toBe(123);
});
it('creates new instance without key', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com', 'user_id' => 123]);
$updated = $payload->without('user_id');
expect($payload->has('user_id'))->toBeTrue();
expect($updated->has('user_id'))->toBeFalse();
});
it('throws exception when removing last key', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com']);
expect(fn () => $payload->without('email'))
->toThrow(InvalidArgumentException::class, 'Payload cannot be empty after removal');
});
it('returns keys and values', function () {
$payload = MagicLinkPayload::fromArray(['email' => 'test@example.com', 'user_id' => 123]);
expect($payload->keys())->toBe(['email', 'user_id']);
expect($payload->values())->toBe(['test@example.com', 123]);
});
});