コード例 #1
0
ファイル: TagFilterTest.php プロジェクト: higrow/Gherkin
 public function testIsFeatureMatchFilter()
 {
     $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1);
     $filter = new TagFilter('@wip');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('wip'), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('~@done');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('wip', 'done'), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('tag1', 'tag2', 'tag3'), null, array(), null, null, null, 1);
     $filter = new TagFilter('@tag5,@tag4,@tag6');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('tag1', 'tag2', 'tag3', 'tag5'), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('@wip&&@vip');
     $feature = new FeatureNode(null, null, array('wip', 'done'), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('wip', 'done', 'vip'), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('@wip,@vip&&@user');
     $feature = new FeatureNode(null, null, array('wip'), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('vip'), null, array(), null, null, null, 1);
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('wip', 'user'), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature = new FeatureNode(null, null, array('vip', 'user'), null, array(), null, null, null, 1);
     $this->assertTrue($filter->isFeatureMatch($feature));
 }
コード例 #2
0
 public function testIsFeatureMatchFilter()
 {
     $feature = new Node\FeatureNode();
     $filter = new TagFilter('@wip');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->addTag('wip');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('~@done');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->addTag('done');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->setTags(array('tag1', 'tag2', 'tag3'));
     $filter = new TagFilter('@tag5,@tag4,@tag6');
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->addTag('tag5');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('@wip&&@vip');
     $feature->setTags(array('wip', 'not-done'));
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->addTag('vip');
     $this->assertTrue($filter->isFeatureMatch($feature));
     $filter = new TagFilter('@wip,@vip&&@user');
     $feature->setTags(array('wip'));
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->setTags(array('vip'));
     $this->assertFalse($filter->isFeatureMatch($feature));
     $feature->setTags(array('wip', 'user'));
     $this->assertTrue($filter->isFeatureMatch($feature));
     $feature->setTags(array('vip', 'user'));
     $this->assertTrue($filter->isFeatureMatch($feature));
 }
コード例 #3
0
 /**
  * Checks if node match tag filter.
  *
  * @param FeatureNode       $feature
  * @param ScenarioInterface $scenario
  * @param string            $filterString
  *
  * @return Boolean
  */
 protected function isMatchTagFilter(FeatureNode $feature, ScenarioInterface $scenario, $filterString)
 {
     $filter = new TagFilter($filterString);
     if ($filter->isFeatureMatch($feature)) {
         return true;
     }
     return $filter->isScenarioMatch($feature, $scenario);
 }
コード例 #4
0
ファイル: FeatureHook.php プロジェクト: unkerror/Budabot
 /**
  * {@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
ファイル: HookDispatcher.php プロジェクト: ryanhouston/Behat
 /**
  * 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 tag filter.
  *
  * @param FeatureNode $feature
  * @param string      $filterString
  *
  * @return Boolean
  */
 private function isMatchTagFilter(FeatureNode $feature, $filterString)
 {
     $filter = new TagFilter($filterString);
     return $filter->isFeatureMatch($feature);
 }