protected function _before() { $container = Robo::createDefaultContainer(); $this->app = $container->get('application'); $config = $container->get('config'); $this->commandFactory = $container->get('commandFactory'); $this->roboCommandFileInstance = new TestedRoboFile(); $builder = $container->get('collectionBuilder', [$this->roboCommandFileInstance]); $this->roboCommandFileInstance->setBuilder($builder); $commandList = $this->commandFactory->createCommandsFromClass($this->roboCommandFileInstance); foreach ($commandList as $command) { $this->app->add($command); } }
/** * @param \Robo\Application $app * @param string|BuilderAwareInterface|ContainerAwareInterface $commandClass * * @return mixed|void */ public function registerCommandClass($app, $commandClass) { $container = Robo::getContainer(); $roboCommandFileInstance = $this->instantiateCommandClass($commandClass); if (!$roboCommandFileInstance) { return; } // Register commands for all of the public methods in the RoboFile. $commandFactory = $container->get('commandFactory'); $commandList = $commandFactory->createCommandsFromClass($roboCommandFileInstance); foreach ($commandList as $command) { $app->add($command); } return $roboCommandFileInstance; }