protected function initialize(InputInterface $input, OutputInterface $output): void
    {
        parent::initialize($input, $output);

        $output->writeln(
            sprintf(
                '<info>Steward</info> <comment>%s</comment> is running the tests...%s',
                $this->getApplication()->getVersion(),
                (!(new CiDetector())->isCiDetected() ? ' Just for you <fg=red><3</fg=red>!' : '')
            )
        );

        // If browser name or env is empty, ends initialization and let the Console/Command fail on input validation
        if (empty($input->getArgument(self::ARGUMENT_BROWSER))
            || empty($input->getArgument(self::ARGUMENT_ENVIRONMENT))
        ) {
            return;
        }

        // Browser name is case insensitive, normalize it to lower case
        $browserNormalized = mb_strtolower($input->getArgument(self::ARGUMENT_BROWSER));

        // Check if browser is supported
        if (!isset($this->supportedBrowsers[$browserNormalized])) {
            throw new \RuntimeException(
                sprintf(
                    'Browser "%s" is not supported (use one of: %s)',
                    $browserNormalized,
                    implode(', ', array_keys($this->supportedBrowsers))
                )
            );
        }

        // Set WebDriver browser identifier back to the argument value
        $input->setArgument(self::ARGUMENT_BROWSER, $this->supportedBrowsers[$browserNormalized]);

        if ($output->isVerbose()) {
            $output->writeln(sprintf('Browser: %s', $input->getArgument(self::ARGUMENT_BROWSER)));
            $output->writeln(sprintf('Environment: %s', $input->getArgument(self::ARGUMENT_ENVIRONMENT)));
        }

        // Initialize Selenium server adapter and normalize server URL
        $seleniumAdapter = $this->getSeleniumAdapter($input->getOption(self::OPTION_SERVER_URL));
        $input->setOption(self::OPTION_SERVER_URL, $seleniumAdapter->getServerUrl());

        // Make sure parallel-limit is greater than 0
        $parallelLimit = (int) $input->getOption(self::OPTION_PARALLEL_LIMIT);
        if ($parallelLimit === 0) {
            throw new \RuntimeException('Parallel limit must be a whole number greater than 0');
        }
        $input->setOption(self::OPTION_PARALLEL_LIMIT, $parallelLimit);

        $this->getDispatcher()->dispatch(
            CommandEvents::RUN_TESTS_INIT,
            new ExtendedConsoleEvent($this, $input, $output)
        );

        if ($output->isVeryVerbose()) {
            $output->writeln(
                sprintf('Path to logs: %s', $this->config[ConfigOptions::LOGS_DIR])
            );
            $output->writeln(
                sprintf('Ignore delays: %s', ($input->getOption(self::OPTION_IGNORE_DELAYS)) ? 'yes' : 'no')
            );
            $output->writeln(
                sprintf('Parallel limit: %d', $input->getOption(self::OPTION_PARALLEL_LIMIT))
            );
        }
    }
protected function initialize(InputInterface $input, OutputInterface $output): void
    {
        parent::initialize($input, $output);

        $output->writeln(
            sprintf(
                '<info>Steward</info> <comment>%s</comment> is running the tests...%s',
                $this->getApplication()->getVersion(),
                (!(new CiDetector())->isCiDetected() ? ' Just for you <fg=red><3</fg=red>!' : '')
            )
        );

        // If browser name or env is empty, ends initialization and let the Console/Command fail on input validation
        if (empty($input->getArgument(self::ARGUMENT_BROWSER))
            || empty($input->getArgument(self::ARGUMENT_ENVIRONMENT))
        ) {
            return;
        }

        // Browser name is case insensitive, normalize it to lower case
        $browserNormalized = mb_strtolower($input->getArgument(self::ARGUMENT_BROWSER));

        // Check if browser is supported
        if (!isset($this->supportedBrowsers[$browserNormalized])) {
            throw new \RuntimeException(
                sprintf(
                    'Browser "%s" is not supported (use one of: %s)',
                    $browserNormalized,
                    implode(', ', array_keys($this->supportedBrowsers))
                )
            );
        }

        // Set WebDriver browser identifier back to the argument value
        $input->setArgument(self::ARGUMENT_BROWSER, $this->supportedBrowsers[$browserNormalized]);

        if ($output->isVerbose()) {
            $output->writeln(sprintf('Browser: %s', $input->getArgument(self::ARGUMENT_BROWSER)));
            $output->writeln(sprintf('Environment: %s', $input->getArgument(self::ARGUMENT_ENVIRONMENT)));
        }

        // Initialize Selenium server adapter and normalize server URL
        $seleniumAdapter = $this->getSeleniumAdapter($input->getOption(self::OPTION_SERVER_URL));
        $input->setOption(self::OPTION_SERVER_URL, $seleniumAdapter->getServerUrl());

        // Make sure parallel-limit is greater than 0
        $parallelLimit = (int) $input->getOption(self::OPTION_PARALLEL_LIMIT);
        if ($parallelLimit === 0) {
            throw new \RuntimeException('Parallel limit must be a whole number greater than 0');
        }
        $input->setOption(self::OPTION_PARALLEL_LIMIT, $parallelLimit);

        $this->getDispatcher()->dispatch(
            CommandEvents::RUN_TESTS_INIT,
            new ExtendedConsoleEvent($this, $input, $output)
        );

        if ($output->isVeryVerbose()) {
            $output->writeln(
                sprintf('Path to logs: %s', $this->config[ConfigOptions::LOGS_DIR])
            );
            $output->writeln(
                sprintf('Ignore delays: %s', ($input->getOption(self::OPTION_IGNORE_DELAYS)) ? 'yes' : 'no')
            );
            $output->writeln(
                sprintf('Parallel limit: %d', $input->getOption(self::OPTION_PARALLEL_LIMIT))
            );
        }
    }
protected function initialize ( InputInterface $ input , OutputInterface $ output ) : void { parent :: initialize ( $ input , $ output ) ; $ output -> writeln ( sprintf ( '<info>Steward</info> <comment>%s</comment> is running the tests...%s' , $ this -> getApplication ( ) -> getVersion ( ) , ( ! ( new CiDetector ( ) ) -> isCiDetected ( ) ? ' Just for you <fg=red><3</fg=red>!' : '' ) ) ) ; // If browser name or env is empty, ends initialization and let the Console/Command fail on input validation if ( empty ( $ input -> getArgument ( self :: ARGUMENT_BROWSER ) ) || empty ( $ input -> getArgument ( self :: ARGUMENT_ENVIRONMENT ) ) ) { return ; } // Browser name is case insensitive, normalize it to lower case $ browserNormalized = mb_strtolower ( $ input -> getArgument ( self :: ARGUMENT_BROWSER ) ) ; // Check if browser is supported if ( ! isset ( $ this -> supportedBrowsers [ $ browserNormalized ] ) ) { throw new \ RuntimeException ( sprintf ( 'Browser "%s" is not supported (use one of: %s)' , $ browserNormalized , implode ( ', ' , array_keys ( $ this -> supportedBrowsers ) ) ) ) ; } // Set WebDriver browser identifier back to the argument value $ input -> setArgument ( self :: ARGUMENT_BROWSER , $ this -> supportedBrowsers [ $ browserNormalized ] ) ; if ( $ output -> isVerbose ( ) ) { $ output -> writeln ( sprintf ( 'Browser: %s' , $ input -> getArgument ( self :: ARGUMENT_BROWSER ) ) ) ; $ output -> writeln ( sprintf ( 'Environment: %s' , $ input -> getArgument ( self :: ARGUMENT_ENVIRONMENT ) ) ) ; } // Initialize Selenium server adapter and normalize server URL $ seleniumAdapter = $ this -> getSeleniumAdapter ( $ input -> getOption ( self :: OPTION_SERVER_URL ) ) ; $ input -> setOption ( self :: OPTION_SERVER_URL , $ seleniumAdapter -> getServerUrl ( ) ) ; // Make sure parallel-limit is greater than 0 $ parallelLimit = ( int ) $ input -> getOption ( self :: OPTION_PARALLEL_LIMIT ) ; if ( $ parallelLimit === 0 ) { throw new \ RuntimeException ( 'Parallel limit must be a whole number greater than 0' ) ; } $ input -> setOption ( self :: OPTION_PARALLEL_LIMIT , $ parallelLimit ) ; $ this -> getDispatcher ( ) -> dispatch ( CommandEvents :: RUN_TESTS_INIT , new ExtendedConsoleEvent ( $ this , $ input , $ output ) ) ; if ( $ output -> isVeryVerbose ( ) ) { $ output -> writeln ( sprintf ( 'Path to logs: %s' , $ this -> config [ ConfigOptions :: LOGS_DIR ] ) ) ; $ output -> writeln ( sprintf ( 'Ignore delays: %s' , ( $ input -> getOption ( self :: OPTION_IGNORE_DELAYS ) ) ? 'yes' : 'no' ) ) ; $ output -> writeln ( sprintf ( 'Parallel limit: %d' , $ input -> getOption ( self :: OPTION_PARALLEL_LIMIT ) ) ) ; } }
Initialize, check arguments and options values etc.
Initialize check arguments and options values etc .