Esempio n. 1
0
 /**
  * Use specified controller.
  *
  * @param string $id
  *
  * @return ControllerChildInterface
  * @throws \InvalidArgumentException
  */
 public function switchTo($id)
 {
     if ($this->container->has($id)) {
         $this->current = $this->container->get($id);
         $this->current->setParent($this);
         if ($this->current instanceof ControllerChildConfigurableInterface) {
             $this->current->setRunner($this->runner);
             $this->current->setPrecondition($this->runner->getPrecondition());
         }
         return $this->current;
     } else {
         throw new \InvalidArgumentException(sprintf('Unknown controller id "%s".', $id));
     }
 }
Esempio n. 2
0
 /**
  * Test filter invalid event listeners.
  *
  * @param $annotation
  * @param $event
  *
  * @dataProvider dpRegisterEventListener
  */
 public function testRegisterEventListener($annotation, $event)
 {
     $method = new \ReflectionMethod($this->runner, 'registerEventListener');
     $method->setAccessible(true);
     $method->invoke($this->runner, $annotation, 'precondition');
     $listeners = $this->runner->getPrecondition()->getListeners();
     $this->assertCount(1, Configurator::getAllInvokes($this->logger));
     $this->assertCount(1, $listeners);
     $this->assertArrayHasKey($event, $listeners);
 }
Esempio n. 3
0
 /**
  * Convert exceptions using context.
  *
  * @param TestMeta $test
  * @param MethodEvent $event
  * @param array $dataSet
  *
  * @return int Status code
  */
 protected function behavior(TestMeta $test, MethodEvent $event, array $dataSet)
 {
     try {
         $statusCode = 0;
         call_user_func_array([$this->runner->getTestCase(), $test->getMethod()], $dataSet);
         if ($test->getExpectedException()) {
             throw new TestFailException('Expected exception ' . $test->getExpectedException());
         }
         $this->finish($test, $event, MethodEvent::METHOD_OK);
     } catch (TestErrorException $exception) {
         $statusCode = $this->context->onError($exception);
         $this->finish($test, $event, MethodEvent::METHOD_FAILED, $exception);
     } catch (IncompleteTestException $exception) {
         $statusCode = $this->context->onIncomplete($exception);
         $this->finish($test, $event, MethodEvent::METHOD_INCOMPLETE, $exception);
     } catch (\Exception $exception) {
         $statusCode = $this->exceptionControl($test, $event, $exception);
     }
     return $statusCode;
 }