Exemple #1
0
 /**
  * Actions after each test.
  *
  * @param MethodEvent $event
  */
 public function afterTest(MethodEvent $event)
 {
     try {
         $this->dispatcher->dispatch(EventStorage::EV_AFTER_TEST, clone $event);
         $this->precondition->dispatch(EventStorage::EV_AFTER_TEST, clone $event);
     } catch (\Exception $exception) {
         $this->context->onAfterTest($exception);
         $event = $this->preconditionFailed($exception);
         /** @var Skip $controller */
         $controller = $this->parent->switchTo(ControllerParentInterface::CONTROLLER_SKIP);
         $controller->setDepends($event->getMethod());
     }
 }
Exemple #2
0
 /**
  * Check specified depends and run test if necessary.
  *
  * @param TestMeta $test
  *
  * @throws \LogicException If found infinitive depends loop
  */
 public function resolveDependencies(TestMeta $test)
 {
     $depends = $test->getDependencies();
     if (empty($depends)) {
         return;
     }
     $test->setStatus(TestMeta::TEST_MARKED);
     foreach ($depends as $depend) {
         $test = $this->getTestMethod($depend);
         if ($test->getStatus() === TestMeta::TEST_NEW) {
             if ($this->testMethod($test)) {
                 /** @var SkipOnce $controller */
                 $controller = $this->controller->switchTo(ControllerParentInterface::CONTROLLER_SKIP_ONCE);
                 $controller->setDepends(null);
             }
         } elseif ($test->getStatus() === TestMeta::TEST_MARKED) {
             throw new \LogicException(sprintf('Found infinitive loop in depends for test method "%s::%s()"', $this->reflectionClass->getName(), $depend));
         } elseif ($test->getStatus() !== TestMeta::TEST_DONE) {
             /** @var SkipOnce $controller */
             $controller = $this->controller->switchTo(ControllerParentInterface::CONTROLLER_SKIP_ONCE);
             $controller->setDepends(null);
         }
     }
 }