ソースを参照

Provides backward compatibility for the CommandTask::subCommands() method

Yves P 10 年 前
コミット
58ca4303d7

+ 1 - 1
src/Shell/Task/CommandTask.php

@@ -186,7 +186,7 @@ class CommandTask extends Shell
             $pluginDot = '';
         }
 
-        if (!in_array($commandName, $this->commands())) {
+        if (!in_array($commandName, $this->commands()) && (empty($pluginDot) && !in_array($name, $this->commands()))) {
             return false;
         }
 

+ 14 - 0
tests/TestCase/Shell/CompletionShellTest.php

@@ -210,6 +210,20 @@ class CompletionShellTest extends TestCase
     }
 
     /**
+     * test that using the dot notation when not mandatory works to provide backward compatibility
+     *
+     * @return void
+     */
+    public function testSubCommandsPluginDotNotationBackwardCompatibility()
+    {
+        $this->Shell->runCommand(['subcommands', 'TestPluginTwo.welcome']);
+        $output = $this->out->output;
+
+        $expected = "say_hello\n";
+        $this->assertTextEquals($expected, $output);
+    }
+
+    /**
      * test that subCommands with an existing plugin command returns the proper sub commands
      *
      * @return void