Example #1
0
 public function testIsScenarioMatchFilter()
 {
     $filter = new NameFilter('scenario1');
     $scenario = new ScenarioNode('UNKNOWN', array(), array(), null, 2);
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $scenario = new ScenarioNode('scenario1', array(), array(), null, 2);
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $scenario = new ScenarioNode('scenario1 title', array(), array(), null, 2);
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $scenario = new ScenarioNode('some scenario title', array(), array(), null, 2);
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $filter = new NameFilter('/sce.ario/');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $filter = new NameFilter('/scen.rio/');
     $this->assertTrue($filter->isScenarioMatch($scenario));
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function filterMatches(HookScope $scope)
 {
     if (!$scope instanceof StepScope) {
         return false;
     }
     if (null === ($filterString = $this->getFilterString())) {
         return true;
     }
     if (!empty($filterString)) {
         $filter = new NameFilter($filterString);
         if ($filter->isFeatureMatch($scope->getFeature())) {
             return true;
         }
         return $this->isStepMatch($scope->getStep(), $filterString);
     }
     return false;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function filterMatches(EventInterface $event)
 {
     if (null === ($filterString = $this->getFilter())) {
         return true;
     }
     $scenario = $event->getStep()->getParent();
     if (false !== strpos($filterString, '@')) {
         $filter = new TagFilter($filterString);
         if ($filter->isScenarioMatch($scenario)) {
             return true;
         }
     } elseif (!empty($filterString)) {
         $filter = new NameFilter($filterString);
         if ($filter->isScenarioMatch($scenario)) {
             return true;
         }
     }
     return false;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function filterMatches(EventInterface $event)
 {
     if (null === ($filterString = $this->getFilter())) {
         return true;
     }
     $feature = $event->getFeature();
     if (false !== strpos($filterString, '@')) {
         $filter = new TagFilter($filterString);
         if ($filter->isFeatureMatch($feature)) {
             return true;
         }
     } elseif (!empty($filterString)) {
         $filter = new NameFilter($filterString);
         if ($filter->isFeatureMatch($feature)) {
             return true;
         }
     }
     return false;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function filterMatches(EventInterface $event)
 {
     if (null === ($filterString = $this->getFilter())) {
         return true;
     }
     if ($event instanceof ScenarioEvent) {
         $scenario = $event->getScenario();
     } else {
         $scenario = $event->getOutline();
     }
     if (false !== strpos($filterString, '@')) {
         $filter = new TagFilter($filterString);
         if ($filter->isScenarioMatch($scenario)) {
             return true;
         }
     } elseif (!empty($filterString)) {
         $filter = new NameFilter($filterString);
         if ($filter->isScenarioMatch($scenario)) {
             return true;
         }
     }
     return false;
 }
 public function testIsScenarioMatchFilter()
 {
     $feature = new Node\FeatureNode();
     $scenario = new Node\ScenarioNode();
     $feature->addScenario($scenario);
     $feature->setTitle('random feature title');
     $scenario->setTitle('UNKNOWN');
     $filter = new NameFilter('feature1');
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $feature->setTitle('feature1');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $feature->setTitle('feature1 title');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $feature->setTitle('some feature1 title');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $feature->setTitle('some feature title');
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $filter = new NameFilter('/fea.ure/');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $feature->setTitle('some feaSure title');
     $scenario->setTitle('some feature title');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $feature->setTitle('some feture title');
     $scenario->setTitle('unk');
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $feature->setTitle('unknown');
     $scenario->setTitle('simple scenario title');
     $filter = new NameFilter('scenario');
     $this->assertTrue($filter->isScenarioMatch($scenario));
     $scenario->setTitle('simple feature title');
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $scenario->setTitle('simple scenerio title');
     $this->assertFalse($filter->isScenarioMatch($scenario));
     $filter = new NameFilter('/scen.rio/');
     $this->assertTrue($filter->isScenarioMatch($scenario));
 }
Example #7
0
 /**
  * Runs step hooks with specified name.
  *
  * @param   string                      $name   hooks name
  * @param   Behat\Behat\Event\StepEvent $event  event to which hooks glued
  */
 protected function fireStepHooks($name, StepEvent $event)
 {
     if (!count($this->hooks)) {
         $this->loadHooks();
     }
     $scenario = $event->getStep()->getParent();
     $hooks = isset($this->hooks[$name]) ? $this->hooks[$name] : array();
     foreach ($hooks as $hook) {
         if (is_callable($hook)) {
             call_user_func($hook, $event);
         } elseif (!empty($hook[0]) && false !== strpos($hook[0], '@')) {
             $filter = new TagFilter($hook[0]);
             if ($filter->isScenarioMatch($scenario)) {
                 call_user_func($hook[1], $event);
             }
         } elseif (!empty($hook[0])) {
             $filter = new NameFilter($hook[0]);
             if ($filter->isScenarioMatch($scenario)) {
                 call_user_func($hook[1], $event);
             }
         } else {
             call_user_func($hook[1], $event);
         }
     }
 }
 /**
  * Checks if scenario matches name filter.
  *
  * @param ScenarioInterface $scenario
  * @param string            $filterString
  *
  * @return Boolean
  */
 protected function isMatchNameFilter(ScenarioInterface $scenario, $filterString)
 {
     $filter = new NameFilter($filterString);
     return $filter->isScenarioMatch($scenario);
 }
Example #9
0
 /**
  * Checks if feature matches name filter.
  *
  * @param FeatureNode $feature
  * @param string      $filterString
  *
  * @return Boolean
  */
 private function isMatchNameFilter(FeatureNode $feature, $filterString)
 {
     $filter = new NameFilter($filterString);
     return $filter->isFeatureMatch($feature);
 }