예제 #1
0
 public function testIsFeatureMatchFilter()
 {
     $feature = new FeatureNode('random feature title', null, array(), null, array(), null, null, null, 1);
     $filter = new NameFilter('feature1');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('feature1', null, array(), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('feature1 title', null, array(), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('some feature1 title', null, array(), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('some feature title', null, array(), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
     $filter = new NameFilter('/fea.ure/');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('some feaSure title', null, array(), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode('some feture title', null, array(), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
 }
예제 #2
0
 public function testIsFeatureMatchFilter()
 {
     $feature = new Node\FeatureNode();
     $feature->setTitle('random feature title');
     $filter = new NameFilter('feature1');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->setTitle('feature1');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTitle('feature1 title');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTitle('some feature1 title');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTitle('some feature title');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $filter = new NameFilter('/fea.ure/');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTitle('some feaSure title');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTitle('some feture title');
     $this->assertFalse($filter->isFeatureMatch($feature));
 }
예제 #3
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;
 }
예제 #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;
 }
예제 #5
0
 /**
  * Runs feature hooks with specified name.
  *
  * @param   string                          $name   hooks name
  * @param   Behat\Behat\Event\FeatureEvent  $event  event to which hooks glued
  */
 protected function fireFeatureHooks($name, FeatureEvent $event)
 {
     if (!count($this->hooks)) {
         $this->loadHooks();
     }
     $feature = $event->getFeature();
     $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->isFeatureMatch($feature)) {
                 call_user_func($hook[1], $event);
             }
         } elseif (!empty($hook[0])) {
             $filter = new NameFilter($hook[0]);
             if ($filter->isFeatureMatch($feature)) {
                 call_user_func($hook[1], $event);
             }
         } else {
             call_user_func($hook[1], $event);
         }
     }
 }
예제 #6
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);
 }