test: add comprehensive tests for Discovery module components

- Add tests for Results registries (AttributeRegistry, InterfaceRegistry, TemplateRegistry)
- Add tests for Processing components (ProcessingContext)
- Add tests for Memory components (MemoryGuard)
- Add tests for Value Objects (DiscoveryOptions, DiscoveryContext)

All new tests pass and cover core functionality including:
- Registry operations (add, get, has, serialize/deserialize, optimize)
- Processing context (reflection caching, file context management)
- Memory guard (memory checks, statistics, emergency cleanup)
- Value objects (factory methods, scan types, cache keys, metrics)
This commit is contained in:
2025-11-10 01:39:57 +01:00
parent 9289344379
commit 43dd602509
7 changed files with 893 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Tests\Framework\Discovery\ValueObjects;
use App\Framework\Discovery\ValueObjects\DiscoveryOptions;
use App\Framework\Discovery\ValueObjects\ScanType;
describe('DiscoveryOptions', function () {
it('can be instantiated with default values', function () {
$options = new DiscoveryOptions();
expect($options)->toBeInstanceOf(DiscoveryOptions::class);
expect($options->scanType)->toBeInstanceOf(ScanType::class);
expect($options->paths)->toBeArray();
expect($options->useCache)->toBeBool();
});
it('can be created with custom values', function () {
$options = new DiscoveryOptions(
scanType: ScanType::FULL,
paths: ['/test/path1', '/test/path2'],
useCache: true
);
expect($options->scanType)->toBe(ScanType::FULL);
expect($options->paths)->toBe(['/test/path1', '/test/path2']);
expect($options->useCache)->toBeTrue();
});
it('can use default factory method', function () {
$options = DiscoveryOptions::default();
expect($options)->toBeInstanceOf(DiscoveryOptions::class);
});
it('can use comprehensive factory method', function () {
$options = DiscoveryOptions::comprehensive();
expect($options)->toBeInstanceOf(DiscoveryOptions::class);
});
it('can use minimal factory method', function () {
$options = DiscoveryOptions::minimal();
expect($options)->toBeInstanceOf(DiscoveryOptions::class);
});
it('supports incremental scan type', function () {
$options = new DiscoveryOptions(
scanType: ScanType::INCREMENTAL,
paths: ['/test/path'],
useCache: false
);
expect($options->scanType)->toBe(ScanType::INCREMENTAL);
});
it('supports full scan type', function () {
$options = new DiscoveryOptions(
scanType: ScanType::FULL,
paths: ['/test/path'],
useCache: true
);
expect($options->scanType)->toBe(ScanType::FULL);
});
});