/** * {@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()); }
public function testRun() { $this->if($locale = new mock\locale())->and($this->calling($locale)->_ = function ($string) { return $string; })->and($helpWriter = new mock\writers\std\out())->and($this->calling($helpWriter)->write = function () { })->and($errorWriter = new mock\writers\std\err())->and($this->calling($errorWriter)->clear = $errorWriter)->and($this->calling($errorWriter)->write = $errorWriter)->and($runner = new mock\runner())->and($this->calling($runner)->getTestPaths = array())->and($this->calling($runner)->getDeclaredTestClasses = array())->and($this->calling($runner)->run = function () { })->and($script = new testedClass($name = uniqid()))->and($script->setLocale($locale))->and($script->setHelpWriter($helpWriter))->and($script->setErrorWriter($errorWriter))->and($script->setRunner($runner))->then->object($script->run())->isIdenticalTo($script)->mock($locale)->call('_')->withArguments('No test found')->once()->mock($errorWriter)->call('write')->withArguments('No test found')->once(); }