- Move 12 markdown files from root to docs/ subdirectories - Organize documentation by category: • docs/troubleshooting/ (1 file) - Technical troubleshooting guides • docs/deployment/ (4 files) - Deployment and security documentation • docs/guides/ (3 files) - Feature-specific guides • docs/planning/ (4 files) - Planning and improvement proposals Root directory cleanup: - Reduced from 16 to 4 markdown files in root - Only essential project files remain: • CLAUDE.md (AI instructions) • README.md (Main project readme) • CLEANUP_PLAN.md (Current cleanup plan) • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements) This improves: ✅ Documentation discoverability ✅ Logical organization by purpose ✅ Clean root directory ✅ Better maintainability
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
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();
|
|
});
|
|
});
|