create( $this->temporaryDirectory, 7, 'abcdef123456abcdef123456', $cacheKey, str_repeat('c', 64), 1000, ); $asset = $paths->asset($this->temporaryDirectory, $cacheKey); mkdir($asset, 0755, true); file_put_contents($asset . '/master.m3u8', '#EXTM3U'); touch($asset, 1000); $cleanup = new CleanupService($config, $paths, new NullLogger()); $result = $cleanup->run($this->temporaryDirectory, 1061); self::assertSame(['sessions' => 1, 'assets' => 1], $result); self::assertNull($sessions->find($this->temporaryDirectory, $created['token'])); self::assertDirectoryDoesNotExist($asset); } public function testActiveSessionPreventsCacheDeletion(): void { $config = new Config(sessionTtl: 120, cacheTtl: 120); $paths = new CachePaths($config); $sessions = new SessionRepository($config, $paths); $cacheKey = str_repeat('a', 64); $sessions->create( $this->temporaryDirectory, 7, 'abcdef123456abcdef123456', $cacheKey, str_repeat('c', 64), 1000, ); $asset = $paths->asset($this->temporaryDirectory, $cacheKey); mkdir($asset, 0755, true); touch($asset, 1); $cleanup = new CleanupService($config, $paths, new NullLogger()); self::assertSame(['sessions' => 0, 'assets' => 0], $cleanup->run($this->temporaryDirectory, 1050)); self::assertDirectoryExists($asset); } }