diff --git a/composer.lock b/composer.lock index b1941b1b3..75ac4e343 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages": [ { "name": "consolidation/annotated-command", - "version": "2.0.0-beta4", + "version": "2.0.0-beta7", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "47d5e634385f379c17ccf547e4a20f48c11b9183" + "reference": "76a15b061124f8a57742854662a58a501133a84a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/47d5e634385f379c17ccf547e4a20f48c11b9183", - "reference": "47d5e634385f379c17ccf547e4a20f48c11b9183", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/76a15b061124f8a57742854662a58a501133a84a", + "reference": "76a15b061124f8a57742854662a58a501133a84a", "shasum": "" }, "require": { @@ -30,7 +30,7 @@ "symfony/finder": "~2.5|~3.0" }, "require-dev": { - "consolidation/output-formatters": "^2.0.0-beta3", + "consolidation/output-formatters": "^2.0.0-beta6", "phpunit/phpunit": "4.*", "satooshi/php-coveralls": "^1.0", "squizlabs/php_codesniffer": "2.*" @@ -60,7 +60,7 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2016-09-19 19:00:17" + "time": "2016-09-23 20:31:13" }, { "name": "consolidation/log", @@ -111,16 +111,16 @@ }, { "name": "consolidation/output-formatters", - "version": "2.0.0-beta5", + "version": "2.0.0-beta7", "source": { "type": "git", "url": "https://github.com/consolidation/output-formatters.git", - "reference": "9f40486dfccd510bb1620a7c0b4ee5dfd6ccd66a" + "reference": "e38a631b56e31b996e621bf87a3e06c59bc29b8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/9f40486dfccd510bb1620a7c0b4ee5dfd6ccd66a", - "reference": "9f40486dfccd510bb1620a7c0b4ee5dfd6ccd66a", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/e38a631b56e31b996e621bf87a3e06c59bc29b8f", + "reference": "e38a631b56e31b996e621bf87a3e06c59bc29b8f", "shasum": "" }, "require": { @@ -155,7 +155,7 @@ } ], "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2016-09-19 19:44:19" + "time": "2016-09-23 21:25:10" }, { "name": "container-interop/container-interop", diff --git a/src/Robo.php b/src/Robo.php index 460609cf3..b974f1aa0 100644 --- a/src/Robo.php +++ b/src/Robo.php @@ -131,11 +131,12 @@ public static function configureContainer(ContainerInterface $container, Config $container->share('resultPrinter', \Robo\Log\ResultPrinter::class); $container->add('simulator', \Robo\Task\Simulator::class); $container->share('globalOptionsEventListener', \Robo\GlobalOptionsEventListener::class); - $container->share('eventDispatcher', \Symfony\Component\EventDispatcher\EventDispatcher::class) - ->withMethodCall('addSubscriber', ['globalOptionsEventListener']); $container->share('collectionProcessHook', \Robo\Collection\CollectionProcessHook::class); $container->share('hookManager', \Consolidation\AnnotatedCommand\Hooks\HookManager::class) ->withMethodCall('addResultProcessor', ['collectionProcessHook', '*']); + $container->share('eventDispatcher', \Symfony\Component\EventDispatcher\EventDispatcher::class) + ->withMethodCall('addSubscriber', ['globalOptionsEventListener']) + ->withMethodCall('addSubscriber', ['hookManager']); $container->share('formatterManager', \Consolidation\OutputFormatters\FormatterManager::class); $container->share('commandProcessor', \Consolidation\AnnotatedCommand\CommandProcessor::class) ->withArgument('hookManager') diff --git a/tests/src/RoboFileFixture.php b/tests/src/RoboFileFixture.php index 94b1ea36c..9d27d9d31 100644 --- a/tests/src/RoboFileFixture.php +++ b/tests/src/RoboFileFixture.php @@ -41,6 +41,27 @@ public function testSymfonyStyle() $this->io()->text('Some text in section two.'); } + /** + * @hook command-event test:command-event + */ + public function hookCommandEvent() + { + $this->io()->text('This is the command-event hook for the test:command-event command.'); + } + + public function testCommandEvent() + { + $this->io()->text('This is the main method for the test:command-event command.'); + } + + /** + * @hook post-command test:command-event + */ + public function hookPostCommand() + { + $this->io()->text('This is the post-command hook for the test:command-event command.'); + } + /** * Demonstrate Robo error output and command failure. */ diff --git a/tests/unit/RunnerTest.php b/tests/unit/RunnerTest.php index ef185dbc1..9a871c93f 100644 --- a/tests/unit/RunnerTest.php +++ b/tests/unit/RunnerTest.php @@ -113,6 +113,19 @@ public function testSymfonyStyle() $this->guy->seeInOutput('Some text in section one.'); } + public function testCommandEventHook() + { + $argv = ['placeholder', 'test:command-event']; + $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream()); + + $expected = <<guy->seeInOutput($expected); + } + public function testRoboStaticRunMethod() { $argv = ['placeholder', 'test:symfony-style'];