@@ -26,7 +26,7 @@ protected function setUp(): void
2626 $ application = new Application ();
2727 $ application ->add ($ this ->command );
2828 $ this ->commandTester = new CommandTester ($ this ->command );
29-
29+
3030 // Create temporary directory for test files
3131 $ this ->tempDir = sys_get_temp_dir () . '/mcp_test_ ' . uniqid ();
3232 mkdir ($ this ->tempDir , 0777 , true );
@@ -56,7 +56,7 @@ public function test_command_configuration(): void
5656 {
5757 $ this ->assertEquals ('mcp:migrate-tool-schema ' , $ this ->command ->getName ());
5858 $ this ->assertEquals ('Migrates a tool class from array-based schema to StructuredSchema ' , $ this ->command ->getDescription ());
59-
59+
6060 $ definition = $ this ->command ->getDefinition ();
6161 $ this ->assertTrue ($ definition ->hasArgument ('class ' ));
6262 $ this ->assertTrue ($ definition ->hasOption ('dry-run ' ));
@@ -95,10 +95,12 @@ public function someOtherMethod() {
9595 public function test_execute_with_class_that_does_not_return_array (): void
9696 {
9797 // Create a test class that returns something other than array
98- $ className = $ this ->createTestClass ('TestClassReturnsString ' , '
99- class TestClassReturnsString {
100- public function getInputSchema(): string {
101- return "not an array";
98+ $ className = $ this ->createTestClass ('TestClassReturnsStructuredSchema ' , '
99+ use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema;
100+
101+ class TestClassReturnsStructuredSchema {
102+ public function getInputSchema(): StructuredSchema {
103+ return new StructuredSchema;
102104 }
103105 }
104106 ' );
@@ -125,7 +127,7 @@ public function getInputSchema(): array {
125127 "description" => "User name"
126128 ],
127129 "age" => [
128- "type" => "integer",
130+ "type" => "integer",
129131 "description" => "User age"
130132 ]
131133 ],
@@ -142,7 +144,7 @@ public function getInputSchema(): array {
142144
143145 $ this ->assertEquals (Command::SUCCESS , $ this ->commandTester ->getStatusCode ());
144146 $ output = $ this ->commandTester ->getDisplay ();
145-
147+
146148 $ this ->assertStringContainsString ('Migrating tool schema for ' , $ output );
147149 $ this ->assertStringContainsString ('Generated Code ' , $ output );
148150 $ this ->assertStringContainsString ('StructuredSchema ' , $ output );
@@ -157,7 +159,6 @@ public function test_generate_schema_property_with_all_parameters(): void
157159 $ command = new MigrateToolSchemaCommand ();
158160 $ reflection = new ReflectionClass ($ command );
159161 $ method = $ reflection ->getMethod ('generateSchemaProperty ' );
160- $ method ->setAccessible (true );
161162
162163 $ config = [
163164 'type ' => 'string ' ,
@@ -179,7 +180,6 @@ public function test_generate_schema_property_minimal(): void
179180 $ command = new MigrateToolSchemaCommand ();
180181 $ reflection = new ReflectionClass ($ command );
181182 $ method = $ reflection ->getMethod ('generateSchemaProperty ' );
182- $ method ->setAccessible (true );
183183
184184 $ config = ['type ' => 'integer ' ];
185185 $ result = $ method ->invoke ($ command , 'simpleProperty ' , $ config , false );
@@ -196,7 +196,6 @@ public function test_map_json_schema_type_to_property_type(): void
196196 $ command = new MigrateToolSchemaCommand ();
197197 $ reflection = new ReflectionClass ($ command );
198198 $ method = $ reflection ->getMethod ('mapJsonSchemaTypeToPropertyType ' );
199- $ method ->setAccessible (true );
200199
201200 $ this ->assertEquals ('STRING ' , $ method ->invoke ($ command , 'string ' ));
202201 $ this ->assertEquals ('INTEGER ' , $ method ->invoke ($ command , 'integer ' ));
@@ -209,7 +208,6 @@ public function test_generate_use_statements_with_existing_statements(): void
209208 $ command = new MigrateToolSchemaCommand ();
210209 $ reflection = new ReflectionClass ($ command );
211210 $ method = $ reflection ->getMethod ('generateUseStatements ' );
212- $ method ->setAccessible (true );
213211
214212 $ contentWithExisting = '<?php
215213namespace Test;
@@ -218,7 +216,7 @@ public function test_generate_use_statements_with_existing_statements(): void
218216class TestClass {} ' ;
219217
220218 $ result = $ method ->invoke ($ command , $ contentWithExisting );
221-
219+
222220 // Should not add StructuredSchema again, but should add the others
223221 $ this ->assertStringNotContainsString ('use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema; ' , $ result );
224222 $ this ->assertStringContainsString ('use KLP\KlpMcpServer\Services\ToolService\Schema\SchemaProperty; ' , $ result );
@@ -230,14 +228,13 @@ public function test_generate_use_statements_with_no_existing_statements(): void
230228 $ command = new MigrateToolSchemaCommand ();
231229 $ reflection = new ReflectionClass ($ command );
232230 $ method = $ reflection ->getMethod ('generateUseStatements ' );
233- $ method ->setAccessible (true );
234231
235232 $ contentWithoutUse = '<?php
236233namespace Test;
237234class TestClass {} ' ;
238235
239236 $ result = $ method ->invoke ($ command , $ contentWithoutUse );
240-
237+
241238 $ this ->assertStringContainsString ('use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema; ' , $ result );
242239 $ this ->assertStringContainsString ('use KLP\KlpMcpServer\Services\ToolService\Schema\SchemaProperty; ' , $ result );
243240 $ this ->assertStringContainsString ('use KLP\KlpMcpServer\Services\ToolService\Schema\PropertyType; ' , $ result );
@@ -248,7 +245,6 @@ public function test_generate_structured_schema_method(): void
248245 $ command = new MigrateToolSchemaCommand ();
249246 $ reflection = new ReflectionClass ($ command );
250247 $ method = $ reflection ->getMethod ('generateStructuredSchemaMethod ' );
251- $ method ->setAccessible (true );
252248
253249 $ schema = [
254250 'type ' => 'object ' ,
@@ -282,7 +278,6 @@ public function test_generate_structured_schema_method_with_empty_schema(): void
282278 $ command = new MigrateToolSchemaCommand ();
283279 $ reflection = new ReflectionClass ($ command );
284280 $ method = $ reflection ->getMethod ('generateStructuredSchemaMethod ' );
285- $ method ->setAccessible (true );
286281
287282 $ schema = [
288283 'type ' => 'object ' ,
@@ -306,10 +301,10 @@ private function createTestClass(string $className, string $classDefinition): st
306301
307302 $ filename = $ this ->tempDir . '/ ' . $ className . '.php ' ;
308303 file_put_contents ($ filename , $ content );
309-
304+
310305 // Include the file so the class is available
311306 include_once $ filename ;
312-
307+
313308 return $ fullClassName ;
314309 }
315310
@@ -333,4 +328,4 @@ public function getInputSchema(): int {
333328 $ output = $ this ->commandTester ->getDisplay ();
334329 $ this ->assertStringContainsString ('getInputSchema does not return an array ' , $ output );
335330 }
336- }
331+ }
0 commit comments