- 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.
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Framework\MagicLinks\ValueObjects\ErrorCollection;
|
|
|
|
describe('ErrorCollection', function () {
|
|
it('creates empty collection', function () {
|
|
$errors = ErrorCollection::empty();
|
|
|
|
expect($errors->isEmpty())->toBeTrue();
|
|
expect($errors->hasErrors())->toBeFalse();
|
|
expect($errors->count())->toBe(0);
|
|
});
|
|
|
|
it('creates collection from array', function () {
|
|
$errors = ErrorCollection::fromArray(['Error 1', 'Error 2']);
|
|
|
|
expect($errors->isEmpty())->toBeFalse();
|
|
expect($errors->hasErrors())->toBeTrue();
|
|
expect($errors->count())->toBe(2);
|
|
});
|
|
|
|
it('creates single error collection', function () {
|
|
$errors = ErrorCollection::single('Test error');
|
|
|
|
expect($errors->count())->toBe(1);
|
|
expect($errors->first())->toBe('Test error');
|
|
});
|
|
|
|
it('adds error immutably', function () {
|
|
$errors = ErrorCollection::empty();
|
|
$updated = $errors->add('New error');
|
|
|
|
expect($errors->count())->toBe(0);
|
|
expect($updated->count())->toBe(1);
|
|
expect($updated->first())->toBe('New error');
|
|
});
|
|
|
|
it('adds multiple errors', function () {
|
|
$errors = ErrorCollection::single('Error 1');
|
|
$updated = $errors->addMultiple(['Error 2', 'Error 3']);
|
|
|
|
expect($updated->count())->toBe(3);
|
|
expect($updated->toArray())->toBe(['Error 1', 'Error 2', 'Error 3']);
|
|
});
|
|
|
|
it('converts to string', function () {
|
|
$errors = ErrorCollection::fromArray(['Error 1', 'Error 2', 'Error 3']);
|
|
|
|
expect($errors->toString())->toBe('Error 1, Error 2, Error 3');
|
|
expect($errors->toString(' | '))->toBe('Error 1 | Error 2 | Error 3');
|
|
});
|
|
|
|
it('returns first error', function () {
|
|
$errors = ErrorCollection::fromArray(['First', 'Second']);
|
|
|
|
expect($errors->first())->toBe('First');
|
|
});
|
|
|
|
it('returns null for empty collection first', function () {
|
|
$errors = ErrorCollection::empty();
|
|
|
|
expect($errors->first())->toBeNull();
|
|
});
|
|
});
|