예제 #1
0
파일: Run.php 프로젝트: komex/unteist
 /**
  * Method was finished.
  *
  * @param TestMeta $test
  * @param MethodEvent $event
  * @param int $status
  * @param \Exception $exception
  */
 private function finish(TestMeta $test, MethodEvent $event, $status, \Exception $exception = null)
 {
     $event->setStatus($status);
     $event->setTime(floatval(microtime(true) - $this->started));
     $event->setAsserts(Assert::getAssertsCount() - $this->asserts);
     $this->asserts = Assert::getAssertsCount();
     if ($status === MethodEvent::METHOD_OK) {
         $test->setStatus(TestMeta::TEST_DONE);
         $this->dispatcher->dispatch(EventStorage::EV_METHOD_DONE, clone $event);
         $this->precondition->dispatch(EventStorage::EV_METHOD_DONE, clone $event);
     } else {
         $event->parseException($exception);
         $context = ['pid' => getmypid(), 'method' => $event->getMethod(), 'exception' => get_class($exception), 'message' => $exception->getMessage()];
         /** @var LoggerInterface $logger */
         $logger = $this->container->get('logger');
         switch ($status) {
             case MethodEvent::METHOD_SKIPPED:
                 $test->setStatus(TestMeta::TEST_SKIPPED);
                 $event->setTime(0);
                 $logger->debug('The test was skipped.', $context);
                 $this->dispatcher->dispatch(EventStorage::EV_METHOD_SKIPPED, clone $event);
                 $this->precondition->dispatch(EventStorage::EV_METHOD_SKIPPED, clone $event);
                 break;
             case MethodEvent::METHOD_FAILED:
                 $test->setStatus(TestMeta::TEST_FAILED);
                 $logger->debug('Assert fail.', $context);
                 $this->dispatcher->dispatch(EventStorage::EV_METHOD_FAILED, clone $event);
                 $this->precondition->dispatch(EventStorage::EV_METHOD_FAILED, clone $event);
                 break;
             case MethodEvent::METHOD_INCOMPLETE:
                 $test->setStatus(TestMeta::TEST_INCOMPLETE);
                 $logger->debug('Test incomplete.', $context);
                 $this->dispatcher->dispatch(EventStorage::EV_METHOD_INCOMPLETE, clone $event);
                 $this->precondition->dispatch(EventStorage::EV_METHOD_INCOMPLETE, clone $event);
                 break;
             default:
                 $test->setStatus(TestMeta::TEST_FAILED);
                 $logger->critical('Unexpected exception.', $context);
                 $this->dispatcher->dispatch(EventStorage::EV_METHOD_FAILED, clone $event);
                 $this->precondition->dispatch(EventStorage::EV_METHOD_FAILED, clone $event);
         }
     }
 }
예제 #2
0
파일: CliReport.php 프로젝트: komex/unteist
 /**
  * Print skipped tests for specified method.
  *
  * @param MethodEvent $method
  */
 private function printSkippedTests(MethodEvent $method)
 {
     $index = 1;
     foreach ($this->skipped as $skipped) {
         if ($method->getClass() !== $skipped->getClass()) {
             continue;
         }
         $depends = $skipped->getDepends();
         if (in_array($method->getMethod(), $depends)) {
             $this->output->writeln("\t" . sprintf('<skipped>%d.</skipped> %s()', $index, $skipped->getMethod()));
         }
         $index++;
     }
 }