createMock(CacheInterface::class); $cache->expects($this->once()) ->method('get') ->willReturn(null); $cache->expects($this->once()) ->method('set') ->willReturn(true); $cachedDiscoverer = new CachedDiscoverer( $discoverer, $cache, new NullLogger() ); $result = $cachedDiscoverer->discover('/test/path', ['.'], []); $this->assertInstanceOf(DiscoveryState::class, $result); } public function testCachedDiscovererReturnsCachedResults(): void { $discoverer = new Discoverer(); $cache = $this->createMock(CacheInterface::class); $cachedState = new DiscoveryState(); $cache->expects($this->once()) ->method('get') ->willReturn($cachedState); $cache->expects($this->never()) ->method('set'); $cachedDiscoverer = new CachedDiscoverer( $discoverer, $cache, new NullLogger() ); $result = $cachedDiscoverer->discover('/test/path', ['.'], []); $this->assertInstanceOf(DiscoveryState::class, $result); } public function testCacheKeyGeneration(): void { $discoverer = new Discoverer(); $cache = $this->createMock(CacheInterface::class); $cache->expects($this->exactly(2)) ->method('get') ->willReturn(null); $cache->expects($this->exactly(2)) ->method('set') ->willReturn(true); $cachedDiscoverer = new CachedDiscoverer( $discoverer, $cache, new NullLogger() ); $result1 = $cachedDiscoverer->discover('/path1', ['.'], []); $result2 = $cachedDiscoverer->discover('/path2', ['.'], []); $this->assertInstanceOf(DiscoveryState::class, $result1); $this->assertInstanceOf(DiscoveryState::class, $result2); } }