Пример #1
0
 /**
  * @see     Behat\Behat\Context\Loader\ContextLoaderInterface::load()
  */
 public function load(ContextInterface $context)
 {
     $reflection = new \ReflectionObject($context);
     foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodRefl) {
         foreach ($this->readMethodAnnotations($reflection->getName(), $methodRefl) as $annotation) {
             if ($annotation instanceof DefinitionInterface) {
                 $this->definitionDispatcher->addDefinition($annotation);
             } elseif ($annotation instanceof TransformationInterface) {
                 $this->definitionDispatcher->addTransformation($annotation);
             } elseif ($annotation instanceof HookInterface) {
                 $this->hookDispatcher->addHook($annotation);
             }
         }
     }
 }
Пример #2
0
 public function load(ContextInterface $context)
 {
     foreach ($this->sitemap->findClasses() as $className) {
         $reflection = new \ReflectionClass($className);
         if ($reflection->isSubclassOf('Behat\\Behat\\Context\\BehatContext')) {
             continue;
         }
         foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodRefl) {
             if ($methodRefl->getDeclaringClass() != $reflection) {
                 continue;
             }
             // only own methods; intentionally != because reflection is not identical
             foreach ($this->readMethodAnnotations($reflection->getName(), $methodRefl) as $annotation) {
                 if ($annotation instanceof \Behat\Behat\Definition\DefinitionInterface) {
                     $this->definitionDispatcher->addDefinition($annotation);
                 } elseif ($annotation instanceof \Behat\Behat\Definition\TransformationInterface) {
                     $this->definitionDispatcher->addTransformation($annotation);
                 } elseif ($annotation instanceof \Behat\Behat\Hook\HookInterface) {
                     $this->hookDispatcher->addHook($annotation);
                 }
             }
         }
     }
 }
Пример #3
0
 /**
  * Hooks into "step.after".
  *
  * @param   string      $filter     filter string (tags or name)
  * @param   Callback    $callback   hook callback
  */
 public function afterStep($filter, $callback)
 {
     $this->dispatcher->addHook(new AfterStep($callback, '' !== $filter ? $filter : null));
 }