Example #1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suiteName = $input->getArgument('suite');
     $this->output = $output;
     $config = Configuration::config($input->getOption('config'));
     $settings = Configuration::suiteSettings($suiteName, $config);
     $options = $input->getOptions();
     $options['debug'] = true;
     $options['silent'] = true;
     $options['interactive'] = false;
     $options['colors'] = true;
     Debug::setOutput(new Output($options));
     $this->codecept = new Codecept($options);
     $dispatcher = $this->codecept->getDispatcher();
     $suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
     $suiteManager->initialize();
     $this->suite = $suiteManager->getSuite();
     $moduleContainer = $suiteManager->getModuleContainer();
     $this->actions = array_keys($moduleContainer->getActions());
     $this->test = (new Cept())->configDispatcher($dispatcher)->configModules($moduleContainer)->configName('')->config('file', '')->initConfig();
     $scenario = new Scenario($this->test);
     if (isset($config["namespace"])) {
         $settings['class_name'] = $config["namespace"] . '\\' . $settings['class_name'];
     }
     $actor = $settings['class_name'];
     $I = new $actor($scenario);
     $this->listenToSignals();
     $output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
     $output->writeln("<info>Try Codeception commands without writing a test</info>");
     $output->writeln("<info>type 'exit' to leave console</info>");
     $output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
     $suiteEvent = new SuiteEvent($this->suite, $this->codecept->getResult(), $settings);
     $dispatcher->dispatch(Events::SUITE_BEFORE, $suiteEvent);
     $dispatcher->dispatch(Events::TEST_PARSED, new TestEvent($this->test));
     $dispatcher->dispatch(Events::TEST_BEFORE, new TestEvent($this->test));
     $output->writeln("\n\n<comment>\$I</comment> = new {$settings['class_name']}(\$scenario);");
     $scenario->stopIfBlocked();
     $this->executeCommands($input, $output, $I, $settings['bootstrap']);
     $dispatcher->dispatch(Events::TEST_AFTER, new TestEvent($this->test));
     $dispatcher->dispatch(Events::SUITE_AFTER, new SuiteEvent($this->suite));
     $output->writeln("<info>Bye-bye!</info>");
 }
Example #2
0
 public function __construct(Scenario $scenario)
 {
     $this->scenario = $scenario;
     $this->scenario->stopIfBlocked();
 }