Skip to content
Permalink
Browse files

Fix backwards compatibility with CommandRunner.

In making the new runner stricter, I dropped the inflection on command
names.

Refs #11174
  • Loading branch information...
markstory committed Sep 13, 2017
1 parent 6829ddd commit f74123b40c3d49299f0691cc7f4ab4b6e0b6a74a
Showing with 27 additions and 0 deletions.
  1. +4 −0 src/Console/CommandRunner.php
  2. +23 −0 tests/TestCase/Console/CommandRunnerTest.php
@@ -23,6 +23,7 @@
use Cake\Event\EventManagerTrait;
use Cake\Shell\HelpShell;
use Cake\Shell\VersionShell;
use Cake\Utility\Inflector;
use RuntimeException;
/**
@@ -169,6 +170,9 @@ protected function getShell(ConsoleIo $io, CommandCollection $commands, $name)
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];
}
if (!$commands->has($name)) {
$name = Inflector::underscore($name);
}
if (!$commands->has($name)) {
throw new RuntimeException(
"Unknown command `{$this->root} {$name}`." .
@@ -208,6 +208,29 @@ public function testRunValidCommand()
$this->assertContains('URI template', $contents);
}
/**
* Test running a valid command and that backwards compatible
* inflection is hooked up.
*
* @return void
*/
public function testRunValidCommandInflection()
{
$app = $this->getMockBuilder(BaseApplication::class)
->setMethods(['middleware', 'bootstrap'])
->setConstructorArgs([$this->config])
->getMock();
$output = new ConsoleOutput();
$runner = new CommandRunner($app, 'cake');
$result = $runner->run(['cake', 'OrmCache', 'build'], $this->getMockIo($output));
$this->assertSame(Shell::CODE_SUCCESS, $result);
$contents = implode("\n", $output->messages());
$this->assertContains('Cache', $contents);
}
/**
* Test running a valid raising an error
*

0 comments on commit f74123b

Please sign in to comment.
You can’t perform that action at this time.