Piwik\Plugins\TestRunner\Commands\TestsRun::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $options = $input->getOption('options');
        $groups = $input->getOption('group');
        $magics = $input->getArgument('variables');
        $groups = $this->getGroupsFromString($groups);
        // bin is the composer executeable directory, where all vendors (should) place their executables
        $command = PIWIK_VENDOR_PATH . '/bin/phpunit';
        if (!$this->isCoverageEnabled($options) && $this->isXdebugLoaded()) {
            $message = 'Did you know? You can run tests faster by disabling xdebug';
            if ($this->isXdebugCodeCoverageEnabled()) {
                $message .= ' (if you need xdebug, speed up tests by setting xdebug.coverage_enable=0)</comment>';
            }
            $output->writeln('<comment>' . $message . '</comment>');
        }
        // force xdebug usage for coverage options
        if ($this->isCoverageEnabled($options) && !$this->isXdebugLoaded()) {
            $output->writeln('<info>xdebug extension required for code coverage.</info>');
            $output->writeln('<info>searching for xdebug extension...</info>');
            $extensionDir = shell_exec('php-config --extension-dir');
            $xdebugFile = trim($extensionDir) . DIRECTORY_SEPARATOR . 'xdebug.so';
            if (!file_exists($xdebugFile)) {
                $dialog = $this->getHelperSet()->get('dialog');
                $xdebugFile = $dialog->askAndValidate($output, 'xdebug not found. Please provide path to xdebug.so', function ($xdebugFile) {
                    return file_exists($xdebugFile);
                });
            } else {
                $output->writeln('<info>xdebug extension found in extension path.</info>');
            }
            $output->writeln("<info>using {$xdebugFile} as xdebug extension.</info>");
            $phpunitPath = trim(shell_exec('which phpunit'));
            $command = sprintf('php -d zend_extension=%s %s', $xdebugFile, $phpunitPath);
        }
        if ($input->getOption('xhprof')) {
            Profiler::setupProfilerXHProf($isMainRun = true);
            putenv('PIWIK_USE_XHPROF=1');
        }
        $suite = $this->getTestsuite($input);
        $testFile = $this->getTestFile($input);
        if (!empty($magics)) {
            foreach ($magics as $magic) {
                if (empty($suite) && in_array($magic, $this->getTestsSuites())) {
                    $suite = $this->buildTestSuiteName($magic);
                } elseif (empty($testFile) && 'core' === $magic) {
                    $testFile = $this->fixPathToTestFileOrDirectory('tests/PHPUnit');
                } elseif (empty($testFile) && 'plugins' === $magic) {
                    $testFile = $this->fixPathToTestFileOrDirectory('plugins');
                } elseif (empty($testFile) && file_exists($magic)) {
                    $testFile = $this->fixPathToTestFileOrDirectory($magic);
                } elseif (empty($testFile) && $this->getPluginTestFolderName($magic)) {
                    $testFile = $this->getPluginTestFolderName($magic);
                } elseif (empty($groups)) {
                    $groups = $this->getGroupsFromString($magic);
                } else {
                    $groups[] = $magic;
                }
            }
        }
        $this->executeTests($suite, $testFile, $groups, $options, $command, $output);
        return $this->returnVar;
    }