Exemplo n.º 1
0
 /**
  * Add a test
  *
  * @param   unittest.TestCase test
  * @return  unittest.TestCase
  * @throws  lang.IllegalArgumentException in case given argument is not a testcase
  * @throws  lang.MethodNotImplementedException in case given argument is not a valid testcase
  */
 public function addTest(TestCase $test)
 {
     if (!$test->getClass()->hasMethod($test->name)) {
         throw new MethodNotImplementedException('Test method does not exist', $test->name);
     }
     $className = $test->getClassName();
     // Verify no special method, e.g. setUp() or tearDown() is overwritten.
     $base = XPClass::forName('unittest.TestCase');
     if ($base->hasMethod($test->name)) {
         throw new IllegalStateException(sprintf('Cannot override %s::%s with test method in %s', $base->getName(), $test->name, $test->getClass()->getMethod($test->name)->getDeclaringClass()->getName()));
     }
     if (!isset($this->order[$className])) {
         $this->order[$className] = array();
     }
     $this->order[$className][] = sizeof($this->tests);
     $this->tests[] = $test;
     return $test;
 }
 /**
  * Write status of currently executing test case
  *
  * @param   unittest.TestCase case
  */
 private function writeStatus(TestCase $case)
 {
     $this->cur++;
     $perc = floor($this->cur / $this->sum * self::PROGRESS_WIDTH);
     $this->out->writef("]2;Running: [%s%s] %s::%s()", str_repeat('*', $perc), str_repeat('-', self::PROGRESS_WIDTH - $perc), $case->getClassName(), $case->getName());
 }