addFilter() публичный Метод

Adds filter to manager.
public addFilter ( Behat\Gherkin\Filter\FeatureFilterInterface $filter )
$filter Behat\Gherkin\Filter\FeatureFilterInterface Feature filter
Пример #1
0
 public function testLoader()
 {
     $gherkin = new Gherkin();
     $gherkin->addLoader($loader = $this->getLoaderMock());
     $gherkin->addFilter($nameFilter = $this->getNameFilterMock());
     $gherkin->addFilter($tagFilter = $this->getTagFilterMock());
     $feature = new FeatureNode();
     $feature->addScenario($scenario = new ScenarioNode());
     $loader->expects($this->once())->method('supports')->with($resource = 'some/feature/resource')->will($this->returnValue(true));
     $loader->expects($this->once())->method('load')->with($resource)->will($this->returnValue(array($feature)));
     $nameFilter->expects($this->once())->method('isScenarioMatch')->with($scenario)->will($this->returnValue(true));
     $tagFilter->expects($this->once())->method('isScenarioMatch')->with($scenario)->will($this->returnValue(true));
     $features = $gherkin->load($resource);
     $this->assertEquals(1, count($features));
     $scenarios = $features[0]->getScenarios();
     $this->assertEquals(1, count($scenarios));
     $this->assertSame($scenario, $scenarios[0]);
 }
Пример #2
0
 public function testLoaderFiltersFeatures()
 {
     $gherkin = new Gherkin();
     $gherkin->addLoader($loader = $this->getLoaderMock());
     $gherkin->addFilter($nameFilter = $this->getNameFilterMock());
     $feature = new FeatureNode();
     $loader->expects($this->once())->method('supports')->with($resource = 'some/feature/resource')->will($this->returnValue(true));
     $loader->expects($this->once())->method('load')->with($resource)->will($this->returnValue(array($feature)));
     $nameFilter->expects($this->once())->method('filterFeature')->with($this->identicalTo($feature));
     $nameFilter->expects($this->once())->method('isFeatureMatch')->with($this->identicalTo($feature))->will($this->returnValue(false));
     $features = $gherkin->load($resource);
     $this->assertEquals(0, count($features));
 }
Пример #3
0
 public function testSetFiltersOverridesAllFilters()
 {
     $gherkin = new Gherkin();
     $gherkin->addLoader($loader = $this->getLoaderMock());
     $gherkin->addFilter($nameFilter = $this->getNameFilterMock());
     $gherkin->setFilters(array());
     $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
     $loader->expects($this->once())->method('supports')->with($resource = 'some/feature/resource')->will($this->returnValue(true));
     $loader->expects($this->once())->method('load')->with($resource)->will($this->returnValue(array($feature)));
     $nameFilter->expects($this->never())->method('filterFeature');
     $nameFilter->expects($this->never())->method('isFeatureMatch');
     $features = $gherkin->load($resource);
     $this->assertEquals(1, count($features));
 }