addJob() public method

Appends new job to queue.
public addJob ( Job $job ) : void
$job Job
return void
示例#1
0
 /**
  * @return void
  */
 public function initiate($file)
 {
     list($annotations, $testName) = $this->getAnnotations($file);
     $php = clone $this->runner->getInterpreter();
     $jobsArgs = array(array());
     foreach (get_class_methods($this) as $method) {
         if (!preg_match('#^initiate(.+)#', strtolower($method), $m) || !isset($annotations[$m[1]])) {
             continue;
         }
         foreach ((array) $annotations[$m[1]] as $value) {
             $res = $this->{$method}($value, $php, $file);
             if ($res && is_int($res[0])) {
                 // [Runner::*, message]
                 $this->runner->writeResult($testName, $res[0], $res[1]);
                 return;
             } elseif ($res && $res[1]) {
                 // [param name, values]
                 $tmp = array();
                 foreach ($res[1] as $val) {
                     foreach ($jobsArgs as $args) {
                         $args[] = Helpers::escapeArg("--{$res['0']}={$val}");
                         $tmp[] = $args;
                     }
                 }
                 $jobsArgs = $tmp;
             }
         }
     }
     foreach ($jobsArgs as $args) {
         $this->runner->addJob(new Job($file, $php, $args));
     }
 }
示例#2
0
 private function initiateTestCase($foo, PhpExecutable $php, $file)
 {
     $job = new Job($file, $php, Helpers::escapeArg(Tester\TestCase::LIST_METHODS));
     $job->run();
     if (in_array($job->getExitCode(), array(Job::CODE_ERROR, Job::CODE_FAIL, Job::CODE_SKIP))) {
         return array($job->getExitCode() === Job::CODE_SKIP ? Runner::SKIPPED : Runner::FAILED, $job->getOutput());
     }
     $methods = json_decode(strrchr($job->getOutput(), '['));
     if (!is_array($methods)) {
         return array(Runner::FAILED, "Cannot list TestCase methods in file '{$file}'. Do you call TestCase::run() in it?");
     } elseif (!$methods) {
         return array(Runner::SKIPPED, "TestCase in file '{$file}' does not contain test methods.");
     }
     foreach ($methods as $method) {
         $this->runner->addJob(new Job($file, $php, Helpers::escapeArg($method)));
     }
     return TRUE;
 }