Beispiel #1
0
 /**
  * Runs the test case.
  * @return void
  */
 public function run($method = NULL)
 {
     $r = new \ReflectionObject($this);
     $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
         return $rm->getName();
     }, $r->getMethods())));
     if (($method === NULL || $method === self::LIST_METHODS) && isset($_SERVER['argv'][1])) {
         if ($_SERVER['argv'][1] === self::LIST_METHODS) {
             Environment::$checkAssertions = FALSE;
             header('Content-Type: application/json');
             echo json_encode($methods);
             return;
         }
         $method = $_SERVER['argv'][1];
     }
     if ($method === NULL) {
         foreach ($methods as $method) {
             $this->runMethod($method);
         }
     } elseif (in_array($method, $methods)) {
         $this->runMethod($method);
     } else {
         throw new TestCaseException("Method '{$method}' does not exist or it is not a testing method.");
     }
 }
Beispiel #2
0
 /**
  * Runs the test case.
  * @return void
  */
 public function run($method = NULL)
 {
     $r = new \ReflectionObject($this);
     $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
         return $rm->getName();
     }, $r->getMethods())));
     if (substr($method, 0, 2) === '--') {
         // back compatibility
         $method = NULL;
     }
     if ($method === NULL && isset($_SERVER['argv']) && ($tmp = preg_filter('#(--method=)?([\\w-]+)$#Ai', '$2', $_SERVER['argv']))) {
         $method = reset($tmp);
         if ($method === self::LIST_METHODS) {
             Environment::$checkAssertions = FALSE;
             header('Content-Type: text/plain');
             echo '[' . implode(',', $methods) . ']';
             return;
         }
     }
     if ($method === NULL) {
         foreach ($methods as $method) {
             $this->runMethod($method);
         }
     } elseif (in_array($method, $methods, TRUE)) {
         $this->runMethod($method);
     } else {
         throw new TestCaseException("Method '{$method}' does not exist or it is not a testing method.");
     }
 }
Beispiel #3
0
 /**
  * Runs the test case.
  * @return void
  */
 public function run()
 {
     if (func_num_args()) {
         throw new \LogicException('Calling TestCase::run($method) is deprecated. Use TestCase::runTest($method) instead.');
     }
     $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
         return $rm->getName();
     }, (new \ReflectionObject($this))->getMethods())));
     if (isset($_SERVER['argv']) && ($tmp = preg_filter('#--method=([\\w-]+)$#Ai', '$1', $_SERVER['argv']))) {
         $method = reset($tmp);
         if ($method === self::LIST_METHODS) {
             Environment::$checkAssertions = FALSE;
             header('Content-Type: text/plain');
             echo '[' . implode(',', $methods) . ']';
             return;
         }
         $this->runTest($method);
     } else {
         foreach ($methods as $method) {
             $this->runTest($method);
         }
     }
 }