getServerScript(), $method) )->mustRun(); $output = $process->getOutput(); $snapshotFile = $this->getSnapshotFilePath($method); if (!file_exists($snapshotFile)) { file_put_contents($snapshotFile, $output.\PHP_EOL); $this->markTestIncomplete("Snapshot created at $snapshotFile, please re-run tests."); } $expected = file_get_contents($snapshotFile); $this->assertJsonStringEqualsJsonString($expected, $output); } /** * List of methods to test. * * @return array */ abstract public static function provideMethods(): array; abstract protected function getServerScript(): string; /** * @return array */ protected static function provideListMethods(): array { return [ 'Prompt Listing' => ['method' => 'prompts/list'], 'Resource Listing' => ['method' => 'resources/list'], // 'Resource Template Listing' => ['method' => 'resources/templates/list'], 'Tool Listing' => ['method' => 'tools/list'], ]; } private function getSnapshotFilePath(string $method): string { $className = substr(static::class, strrpos(static::class, '\\') + 1); return __DIR__.'/snapshots/'.$className.'-'.str_replace('/', '_', $method).'.json'; } }