Example #1
0
 /**
  * Run TestCase.
  *
  * @param TestCase $testCase
  *
  * @return int Status code
  */
 public function run(TestCase $testCase)
 {
     $this->precondition($testCase);
     if ($this->tests->count() == 0) {
         $this->logger->notice('Tests not found in TestCase', ['pid' => getmypid()]);
         /** @var EventDispatcherInterface $dispatcher */
         $dispatcher = $this->container->get('dispatcher');
         $dispatcher->dispatch(EventStorage::EV_CASE_FILTERED);
         return 1;
     }
     $statusCode = 0;
     $testCaseEvent = new TestCaseEvent($this->reflectionClass->getName());
     $testCaseEvent->setAnnotations(self::getAnnotations($this->reflectionClass->getDocComment()));
     $this->controller->beforeCase($testCaseEvent);
     foreach ($this->tests as $test) {
         if ($test->getStatus() !== TestMeta::TEST_NEW && $test->getStatus() !== TestMeta::TEST_MARKED) {
             continue;
         }
         if ($this->testMethod($test)) {
             $statusCode = 1;
         }
     }
     $this->controller->afterCase($testCaseEvent);
     return $statusCode;
 }
Example #2
0
 /**
  * Generate TestCase report.
  *
  * @param TestCaseEvent $event TestCase information
  */
 public function onAfterTestCase(TestCaseEvent $event)
 {
     $methods = $this->storage[$event->getClass()];
     $statistics = $this->statistics->add($event, $methods);
     $content = $this->twig->render('case.html.twig', ['case' => $methods, 'event' => $event, 'statistics' => $statistics]);
     $path = $this->getPathByNamespace($event->getClass(), true);
     $this->fs->mkdir($path);
     file_put_contents($path . DIRECTORY_SEPARATOR . 'index.html', $content);
 }