/** * Executes controller. * * @param InputInterface $input * @param OutputInterface $output * * @return null|integer */ public function execute(InputInterface $input, OutputInterface $output) { $filters = array(); foreach ($input->getOption('name') as $name) { $filters[] = new NameFilter($name); } foreach ($input->getOption('tags') as $tags) { $filters[] = new TagFilter($tags); } if ($role = $input->getOption('role')) { $filters[] = new RoleFilter($role); } if (count($filters)) { $this->gherkin->setFilters($filters); } }
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)); }