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);
 }