@@ -202,5 +202,67 @@ public function testExecuteWithUnsupportedPlatformThrowsException()
202202 'message ' => 'Test message ' ,
203203 ]);
204204 }
205+
206+ public function testExecuteWithVertexAiPlatform ()
207+ {
208+ $ platforms = $ this ->createMock (ServiceLocator::class);
209+ $ mockPlatform = $ this ->createMock (PlatformInterface::class);
210+ $ platforms ->method ('getProvidedServices ' )->willReturn (['vertexai ' => 'service_class ' ]);
211+ $ platforms ->method ('has ' )->with ('vertexai ' )->willReturn (true );
212+ $ platforms ->method ('get ' )->with ('vertexai ' )->willReturn ($ mockPlatform );
213+
214+ $ command = new PlatformInvokeCommand ($ platforms );
215+
216+ // This should not throw an exception since vertexai is supported
217+ $ commandTester = new CommandTester ($ command );
218+ $ commandTester ->setInputs (['exit ' ]); // Mock user input for chat
219+
220+ try {
221+ $ commandTester ->execute ([
222+ 'platform ' => 'vertexai ' ,
223+ 'model ' => 'gemini-pro ' ,
224+ 'message ' => 'Test message ' ,
225+ ]);
226+ // If we get here without exception, the platform is properly supported
227+ $ this ->assertTrue (true );
228+ } catch (InvalidArgumentException $ e ) {
229+ if (str_contains ($ e ->getMessage (), 'not supported ' )) {
230+ $ this ->fail ('VertexAI platform should be supported but got: ' .$ e ->getMessage ());
231+ }
232+ // Other exceptions are fine (like platform invoke errors)
233+ $ this ->assertTrue (true );
234+ }
235+ }
236+
237+ public function testExecuteWithPerplexityPlatform ()
238+ {
239+ $ platforms = $ this ->createMock (ServiceLocator::class);
240+ $ mockPlatform = $ this ->createMock (PlatformInterface::class);
241+ $ platforms ->method ('getProvidedServices ' )->willReturn (['perplexity ' => 'service_class ' ]);
242+ $ platforms ->method ('has ' )->with ('perplexity ' )->willReturn (true );
243+ $ platforms ->method ('get ' )->with ('perplexity ' )->willReturn ($ mockPlatform );
244+
245+ $ command = new PlatformInvokeCommand ($ platforms );
246+
247+ // This should not throw an "unsupported" exception since perplexity is now supported
248+ $ commandTester = new CommandTester ($ command );
249+ $ commandTester ->setInputs (['exit ' ]); // Mock user input for chat
250+
251+ try {
252+ $ commandTester ->execute ([
253+ 'platform ' => 'perplexity ' ,
254+ 'model ' => 'sonar ' ,
255+ 'message ' => 'Test message ' ,
256+ ]);
257+ // If we get here without exception, the platform is properly supported
258+ $ this ->assertTrue (true );
259+ } catch (InvalidArgumentException $ e ) {
260+ if (str_contains ($ e ->getMessage (), 'not supported ' )) {
261+ $ this ->fail ('Perplexity platform should be supported but got: ' .$ e ->getMessage ());
262+ }
263+ // Other exceptions are fine (like platform invoke errors)
264+ $ this ->assertTrue (true );
265+ }
266+ }
205267}
206268
0 commit comments