mageekguy\atoum\scripts\runner::run PHP Method

run() public method

public run ( array $arguments = [] )
$arguments array
    public function run(array $arguments = array())
    {
        # Default bootstrap file MUST be included here because some arguments on the command line can include some tests which depends of this file.
        # So, this file must be included BEFORE argument parsing which is done in script::run().
        # Default bootstrap file can be overrided in a default config file included in script\configurable::run() which extends script::run().
        # So, if a bootstrap file is defined in a default config file, it will be available when arguments on CLI will be parsed
        $this->setDefaultBootstrapFiles();
        if ($this->autorun() === true && sizeof($this->runner->getDeclaredTestClasses()) > 0) {
            $this->runner->canNotAddTest();
        }
        try {
            parent::run($arguments ?: $this->getArguments());
        } catch (atoum\exception $exception) {
            $this->writeError($exception->getMessage());
            exit(2);
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new runner('atoum');
     $bundles = $input->getArgument('bundles');
     if (count($bundles) > 0) {
         foreach ($bundles as $k => $bundleName) {
             $bundles[$k] = $this->extractBundleConfigurationFromKernel($bundleName);
         }
     } else {
         $bundles = $this->getContainer()->get('atoum.configuration.bundle.container')->all();
     }
     foreach ($bundles as $bundle) {
         $directories = array_filter($bundle->getDirectories(), function ($dir) {
             return is_dir($dir);
         });
         if (empty($directories)) {
             $output->writeln(sprintf('<error>There is no test found on "%s".</error>', $bundle->getName()));
         }
         foreach ($directories as $directory) {
             $runner->getRunner()->addTestsFromDirectory($directory);
         }
     }
     $defaultBootstrap = sprintf('%s/autoload.php', $this->getApplication()->getKernel()->getRootDir());
     $bootstrap = $input->getOption('bootstrap-file') ?: $defaultBootstrap;
     $this->setAtoumArgument('--bootstrap-file', $bootstrap);
     if ($input->getOption('no-code-coverage')) {
         $this->setAtoumArgument('-ncc');
     }
     if ($input->getOption('max-children-number')) {
         $this->setAtoumArgument('--max-children-number', (int) $input->getOption('max-children-number'));
     }
     $runner->run($this->getAtoumArguments());
 }
All Usage Examples Of mageekguy\atoum\scripts\runner::run