toBeInstanceOf(DiscoveryContext::class); }); it('can track processed files', function () { $context = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: new DiscoveryOptions(), startTime: new \DateTimeImmutable() ); expect($context->getProcessedFiles())->toBe(0); $context->incrementProcessedFiles(); $context->incrementProcessedFiles(); expect($context->getProcessedFiles())->toBe(2); }); it('can add and retrieve metrics', function () { $context = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: new DiscoveryOptions(), startTime: new \DateTimeImmutable() ); $context->addMetric('files_scanned', 10); $context->addMetric('errors', 2); $metrics = $context->getMetrics(); expect($metrics)->toBeArray(); expect($metrics)->toHaveKey('files_scanned'); expect($metrics)->toHaveKey('errors'); expect($metrics['files_scanned'])->toBe(10); expect($metrics['errors'])->toBe(2); }); it('can check if incremental', function () { $incrementalContext = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::INCREMENTAL, options: new DiscoveryOptions(), startTime: new \DateTimeImmutable() ); expect($incrementalContext->isIncremental())->toBeTrue(); $fullContext = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: new DiscoveryOptions(), startTime: new \DateTimeImmutable() ); expect($fullContext->isIncremental())->toBeFalse(); }); it('can check if should use cache', function () { $cachedOptions = new DiscoveryOptions(useCache: true); $context = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: $cachedOptions, startTime: new \DateTimeImmutable() ); expect($context->shouldUseCache())->toBeTrue(); $noCacheOptions = new DiscoveryOptions(useCache: false); $context2 = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: $noCacheOptions, startTime: new \DateTimeImmutable() ); expect($context2->shouldUseCache())->toBeFalse(); }); it('can generate cache key', function () { $context = new DiscoveryContext( paths: ['/test/path'], scanType: ScanType::FULL, options: new DiscoveryOptions(), startTime: new \DateTimeImmutable() ); $cacheKey = $context->getCacheKey(); expect($cacheKey)->toBeInstanceOf(\App\Framework\Cache\CacheKey::class); }); it('can use default factory method', function () { $context = DiscoveryContext::default(); expect($context)->toBeInstanceOf(DiscoveryContext::class); expect($context->paths)->toBeArray(); }); it('can use comprehensive factory method', function () { $context = DiscoveryContext::comprehensive(); expect($context)->toBeInstanceOf(DiscoveryContext::class); }); it('can use minimal factory method', function () { $context = DiscoveryContext::minimal(); expect($context)->toBeInstanceOf(DiscoveryContext::class); expect($context->isIncremental())->toBeTrue(); }); });