src/DunitCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        // retrieve the current settings
        $options = $this->getCurrentOptions($input, $output);

        // check if docker is installed
        if (false === $this->commandExists('docker')) {
            $output->writeln('Docker is required to run DUnit.');
            return self::ERROR_CODE;
        }
        // loop over each of the docker images specified
        foreach ($options[self::OPTIONS_KEY_IMAGES] as $image) {
            if ($options[self::OPTIONS_KEY_PULL]) {
                passthru(sprintf(
                    self::DOCKER_COMMAND_PULL,
                    escapeshellarg($image)
                ));
                continue;
            }

            $output->writeln('Running against image '.$image);
            if ($options[self::OPTIONS_KEY_SYNTAX]) {
                $output->writeln('Checking syntax');
                // run the syntax checks
                $this->executeCommandForImage(
                    $image,
                    $options[self::OPTIONS_KEY_SYNTAXCOMMAND]
                );
            }
            if ($options[self::OPTIONS_KEY_UNITTESTS]) {
                $output->writeln('Running unit test suite');
                // run the unit tests
                $this->executeCommandForImage(
                    $image,
                    $options[self::OPTIONS_KEY_UNITTESTSCOMMAND]
                );
            }
        }
        return self::NO_ERROR;
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        // retrieve the current settings
        $options = $this->getCurrentOptions($input, $output);

        // check if docker is installed
        if (false === $this->commandExists('docker')) {
            $output->writeln('Docker is required to run DUnit.');
            return self::ERROR_CODE;
        }
        // loop over each of the docker images specified
        foreach ($options[self::OPTIONS_KEY_IMAGES] as $image) {
            if ($options[self::OPTIONS_KEY_PULL]) {
                passthru(sprintf(
                    self::DOCKER_COMMAND_PULL,
                    escapeshellarg($image)
                ));
                continue;
            }

            $output->writeln('Running against image '.$image);
            if ($options[self::OPTIONS_KEY_SYNTAX]) {
                $output->writeln('Checking syntax');
                // run the syntax checks
                $this->executeCommandForImage(
                    $image,
                    $options[self::OPTIONS_KEY_SYNTAXCOMMAND]
                );
            }
            if ($options[self::OPTIONS_KEY_UNITTESTS]) {
                $output->writeln('Running unit test suite');
                // run the unit tests
                $this->executeCommandForImage(
                    $image,
                    $options[self::OPTIONS_KEY_UNITTESTSCOMMAND]
                );
            }
        }
        return self::NO_ERROR;
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { // retrieve the current settings $ options = $ this -> getCurrentOptions ( $ input , $ output ) ; // check if docker is installed if ( false === $ this -> commandExists ( 'docker' ) ) { $ output -> writeln ( 'Docker is required to run DUnit.' ) ; return self :: ERROR_CODE ; } // loop over each of the docker images specified foreach ( $ options [ self :: OPTIONS_KEY_IMAGES ] as $ image ) { if ( $ options [ self :: OPTIONS_KEY_PULL ] ) { passthru ( sprintf ( self :: DOCKER_COMMAND_PULL , escapeshellarg ( $ image ) ) ) ; continue ; } $ output -> writeln ( 'Running against image ' . $ image ) ; if ( $ options [ self :: OPTIONS_KEY_SYNTAX ] ) { $ output -> writeln ( 'Checking syntax' ) ; // run the syntax checks $ this -> executeCommandForImage ( $ image , $ options [ self :: OPTIONS_KEY_SYNTAXCOMMAND ] ) ; } if ( $ options [ self :: OPTIONS_KEY_UNITTESTS ] ) { $ output -> writeln ( 'Running unit test suite' ) ; // run the unit tests $ this -> executeCommandForImage ( $ image , $ options [ self :: OPTIONS_KEY_UNITTESTSCOMMAND ] ) ; } } return self :: NO_ERROR ; }
The entry point for the command.
@param InputInterface $input The input for options and arguments.
@param OutputInterface $output The output writer.
@return null|int null or 0 if everything went fine, or an error code
The entry point for the command .