@@ -19,20 +19,42 @@ abstract class InspectorSnapshotTestCase extends TestCase
1919{
2020 private const INSPECTOR_VERSION = '0.16.8 ' ;
2121
22+ /**
23+ * @param array<string, mixed> $toolArgs
24+ */
2225 #[DataProvider('provideMethods ' )]
23- public function testResourcesListOutputMatchesSnapshot (string $ method ): void
24- {
25- $ process = (new Process ([
26- 'npx ' ,
27- \sprintf ('@modelcontextprotocol/inspector@%s ' , self ::INSPECTOR_VERSION ),
28- '--cli ' ,
29- 'php ' ,
30- $ this ->getServerScript (),
31- '--method ' ,
32- $ method ,
33- ]))->mustRun ();
34-
35- $ output = $ process ->getOutput ();
26+ public function testMethodOutputMatchesSnapshot (
27+ string $ method ,
28+ ?string $ toolName = null ,
29+ array $ toolArgs = [],
30+ ?string $ uri = null ,
31+ ): void {
32+ $ inspector = \sprintf ('@modelcontextprotocol/inspector@%s ' , self ::INSPECTOR_VERSION );
33+ $ args = [
34+ 'npx ' , $ inspector , '--cli ' , 'php ' , $ this ->getServerScript (), '--method ' , $ method ,
35+ ];
36+
37+ // Options for tools/call
38+ if (null !== $ toolName ) {
39+ $ args [] = '--tool-name ' ;
40+ $ args [] = $ toolName ;
41+
42+ foreach ($ toolArgs as $ key => $ value ) {
43+ $ args [] = '--tool-arg ' ;
44+ $ args [] = \sprintf ('%s=%s ' , $ key , $ value );
45+ }
46+ }
47+
48+ // Options for resources/read
49+ if (null !== $ uri ) {
50+ $ args [] = '--uri ' ;
51+ $ args [] = $ uri ;
52+ }
53+
54+ $ output = (new Process ($ args ))
55+ ->mustRun ()
56+ ->getOutput ();
57+
3658 $ snapshotFile = $ this ->getSnapshotFilePath ($ method );
3759
3860 if (!file_exists ($ snapshotFile )) {
0 commit comments