Files
michaelschiemer/tests/Unit/Framework/MagicLinks/TokenActionTest.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

81 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Framework\MagicLinks\TokenAction;
describe('TokenAction Value Object', function () {
it('creates valid action', function () {
$action = new TokenAction('email_verification');
expect($action->name)->toBe('email_verification');
expect((string) $action)->toBe('email_verification');
});
it('allows lowercase letters and underscores', function () {
$validActions = [
'email_verification',
'password_reset',
'document_access',
'user_invitation',
'simple',
'with_multiple_underscores',
];
foreach ($validActions as $actionName) {
$action = new TokenAction($actionName);
expect($action->name)->toBe($actionName);
}
});
it('rejects empty name', function () {
expect(fn() => new TokenAction(''))
->toThrow(\InvalidArgumentException::class, 'Action name cannot be empty');
});
it('rejects uppercase letters', function () {
expect(fn() => new TokenAction('EmailVerification'))
->toThrow(\InvalidArgumentException::class, 'Action name must contain only lowercase letters and underscores');
});
it('rejects numbers', function () {
expect(fn() => new TokenAction('action123'))
->toThrow(\InvalidArgumentException::class, 'Action name must contain only lowercase letters and underscores');
});
it('rejects hyphens', function () {
expect(fn() => new TokenAction('email-verification'))
->toThrow(\InvalidArgumentException::class, 'Action name must contain only lowercase letters and underscores');
});
it('rejects spaces', function () {
expect(fn() => new TokenAction('email verification'))
->toThrow(\InvalidArgumentException::class, 'Action name must contain only lowercase letters and underscores');
});
it('rejects special characters', function () {
$invalidActions = ['action@test', 'action.test', 'action!', 'action#', 'action$'];
foreach ($invalidActions as $actionName) {
expect(fn() => new TokenAction($actionName))
->toThrow(\InvalidArgumentException::class);
}
});
it('compares actions correctly', function () {
$action1 = new TokenAction('email_verification');
$action2 = new TokenAction('email_verification');
$action3 = new TokenAction('password_reset');
expect($action1->equals($action2))->toBeTrue();
expect($action1->equals($action3))->toBeFalse();
});
it('converts to string', function () {
$action = new TokenAction('document_access');
expect($action->__toString())->toBe('document_access');
expect((string) $action)->toBe('document_access');
});
});