Browse Source

#13313 Completion command should ignore methods from core Shell

Marcelo Rocha 6 years ago
parent
commit
5c33f44eda

+ 8 - 1
tests/TestCase/Command/CompletionCommandTest.php

@@ -214,7 +214,6 @@ class CompletionCommandTest extends ConsoleIntegrationTestCase
     {
         $this->exec('completion subcommands sample');
         $this->assertExitCode(Shell::CODE_SUCCESS);
-
         $expected = [
             'derp',
             'load',
@@ -225,6 +224,14 @@ class CompletionCommandTest extends ConsoleIntegrationTestCase
         foreach ($expected as $value) {
             $this->assertOutputContains($value);
         }
+        //Methods overwritten from Shell class should not be included
+        $notExpected = [
+            'runCommand',
+            'getOptionParser'
+        ];
+        foreach($notExpected as $method) {
+            $this->assertOutputNotContains($method);
+        }
     }
 
     /**

+ 18 - 0
tests/test_app/TestApp/Shell/SampleShell.php

@@ -22,12 +22,14 @@ declare(strict_types=1);
  */
 namespace TestApp\Shell;
 
+use Cake\Console\ConsoleOptionParser;
 use Cake\Console\Shell;
 
 class SampleShell extends Shell
 {
     public $tasks = ['Sample', 'Load'];
 
+
     /**
      * main method
      *
@@ -57,4 +59,20 @@ class SampleShell extends Shell
     {
         return 99;
     }
+
+    /**
+     * @inheritDoc
+     */
+    public function runCommand(array $argv, bool $autoMethod = false, array $extra = [])
+    {
+        return parent::runCommand($argv, $autoMethod, $extra);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getOptionParser(): ConsoleOptionParser
+    {
+        return parent::getOptionParser();
+    }
 }