@@ -150,23 +150,31 @@ protected static function ajax(string $method, string $uri, array $params = [],
150150 /**
151151 * Execute a command and return output.
152152 *
153- * @param string $name Command name (e.g. "app:send")
154- * @param Command $command Command instance (e.g. new SendCommand())
155- * @param array $arguments Possible command arguments and options
156- * @param array $otherCommands Possible other commands to define
157- * @param ?array $inputs Possible inputs to set inside command
153+ * @param string $name Command name (e.g. "app:send")
154+ * @param callable|object $command Command instance (e.g. new SendCommand())
155+ * @param array $arguments Possible command arguments and options
156+ * @param array $otherCommands Possible other commands to define
157+ * @param ?array $inputs Possible inputs to set inside command
158158 */
159159 protected static function commandTest (
160160 string $ name ,
161- Command $ command ,
161+ callable | object $ command ,
162162 array $ arguments = [],
163163 array $ otherCommands = [],
164164 ?array $ inputs = null ,
165165 ): string {
166166 $ application = new Application (self ::$ client ->getKernel ());
167- $ application ->add ($ command );
168- foreach ($ otherCommands as $ otherCommand ) {
169- $ application ->add ($ otherCommand );
167+ // @phpstan-ignore-next-line function.alreadyNarrowedType
168+ if (\method_exists ($ application , 'addCommand ' )) {
169+ $ application ->addCommand ($ command );
170+ foreach ($ otherCommands as $ otherCommand ) {
171+ $ application ->addCommand ($ otherCommand );
172+ }
173+ } else {
174+ $ application ->add ($ command );
175+ foreach ($ otherCommands as $ otherCommand ) {
176+ $ application ->add ($ otherCommand );
177+ }
170178 }
171179 $ cmd = $ application ->find ($ name );
172180 $ commandTester = new CommandTester ($ cmd );
0 commit comments