Skip to content
Permalink
Browse files

Plugin classes should discover their own shell commands.

Containing plugin command loading to the plugin makes it easier for
plugin developers to modify/replace the conventions/default behavior.
  • Loading branch information...
markstory committed Mar 9, 2018
1 parent d96c600 commit dbccf7d677a2eb876d4207f8d117a6f4e95cae90
Showing with 17 additions and 2 deletions.
  1. +1 −1 src/Core/BasePlugin.php
  2. +1 −0 src/Core/Plugin.php
  3. +15 −1 tests/TestCase/Core/BasePluginTest.php
@@ -246,7 +246,7 @@ public function bootstrap(PluginApplicationInterface $app)
*/
public function console($commands)
{
return $commands;
return $commands->addMany($commands->discoverPlugin($this->getName()));
}
/**
@@ -126,6 +126,7 @@ public static function load($plugin, array $config = [])
'autoload' => false,
'bootstrap' => false,
'routes' => false,
'console' => true,
'classBase' => 'src',
'ignoreMissing' => false,
'name' => $plugin
@@ -81,13 +81,27 @@ public function testMiddleware()
$this->assertSame($middleware, $plugin->middleware($middleware));
}
public function testConsole()
public function testConsoleNoop()
{
$plugin = new BasePlugin();
$commands = new CommandCollection();
$this->assertSame($commands, $plugin->console($commands));
}
public function testConsoleFind()
{
$plugin = new TestPlugin();
Plugin::getCollection()->add($plugin);
$result = $plugin->console(new CommandCollection());
$this->assertTrue($result->has('widget'), 'Should have plugin command added');
$this->assertTrue($result->has('test_plugin.widget'), 'Should have long plugin name');
$this->assertTrue($result->has('example'), 'Should have plugin shell added');
$this->assertTrue($result->has('test_plugin.example'), 'Should have long plugin name');
}
public function testBootstrap()
{
$app = $this->createMock(PluginApplicationInterface::class);

0 comments on commit dbccf7d

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