2 namespace Robo\Task\Testing;
4 use Robo\Contract\CommandInterface;
5 use Robo\Contract\PrintedInterface;
6 use Robo\Task\BaseTask;
9 * Runs [atoum](http://atoum.org/) tests
14 * ->files('path/to/test.php')
15 * ->configFile('config/dev.php')
21 class Atoum extends BaseTask implements CommandInterface, PrintedInterface
23 use \Robo\Common\ExecOneCommand;
33 * @param null|string $pathToAtoum
35 * @throws \Robo\Exception\TaskException
37 public function __construct($pathToAtoum = null)
39 $this->command = $pathToAtoum;
40 if (!$this->command) {
41 $this->command = $this->findExecutable('atoum');
43 if (!$this->command) {
44 throw new \Robo\Exception\TaskException(__CLASS__, "Neither local atoum nor global composer installation not found");
49 * Tag or Tags to filter.
51 * @param string|array $tags
55 public function tags($tags)
57 return $this->addMultipleOption('tags', $tags);
61 * Display result using the light reporter.
65 public function lightReport()
67 $this->option("--use-light-report");
73 * Display result using the tap reporter.
79 $this->option("use-tap-report");
85 * Path to the bootstrap file.
91 public function bootstrap($file)
93 $this->option("bootstrap", $file);
99 * Path to the config file.
101 * @param string $file
105 public function configFile($file)
107 $this->option('-c', $file);
113 * Use atoum's debug mode.
117 public function debug()
119 $this->option("debug");
125 * Test file or test files to run.
127 * @param string|array
131 public function files($files)
133 return $this->addMultipleOption('f', $files);
137 * Test directory or directories to run.
139 * @param string|array A single directory or a list of directories.
143 public function directories($directories)
145 return $this->addMultipleOption('directories', $directories);
149 * @param string $option
150 * @param string|array $values
154 protected function addMultipleOption($option, $values)
156 if (is_string($values)) {
160 foreach ($values as $value) {
161 $this->option($option, $value);
170 public function getCommand()
172 return $this->command . $this->arguments;
178 public function run()
180 $this->printTaskInfo('Running atoum ' . $this->arguments);
182 return $this->executeCommand($this->getCommand());