public function testTags() { $outline = new OutlineNode(); $this->assertFalse($outline->hasTags()); $this->assertInternalType('array', $outline->getTags()); $this->assertEquals(0, count($outline->getTags())); $outline->setTags($tags = array('tag1', 'tag2')); $this->assertEquals($tags, $outline->getTags()); $outline->addTag('tag3'); $this->assertEquals(array('tag1', 'tag2', 'tag3'), $outline->getTags()); $this->assertFalse($outline->hasTag('tag4')); $this->assertTrue($outline->hasTag('tag2')); $this->assertTrue($outline->hasTag('tag3')); }
/** * Filters feature according to the filter and returns new one. * * @param FeatureNode $feature * * @return FeatureNode */ public function filterFeature(FeatureNode $feature) { $scenarios = array(); foreach ($feature->getScenarios() as $scenario) { if (!$this->isScenarioMatch($scenario)) { continue; } if ($scenario instanceof OutlineNode && $scenario->hasExamples()) { $table = $scenario->getExampleTable()->getTable(); $lines = array_keys($table); if (in_array($this->filterLine, $lines)) { $filteredTable = array($lines[0] => $table[$lines[0]]); if ($lines[0] !== $this->filterLine) { $filteredTable[$this->filterLine] = $table[$this->filterLine]; } $scenario = new OutlineNode($scenario->getTitle(), $scenario->getTags(), $scenario->getSteps(), new ExampleTableNode($filteredTable, $scenario->getExampleTable()->getKeyword()), $scenario->getKeyword(), $scenario->getLine()); } } $scenarios[] = $scenario; } return new FeatureNode($feature->getTitle(), $feature->getDescription(), $feature->getTags(), $feature->getBackground(), $scenarios, $feature->getKeyword(), $feature->getLanguage(), $feature->getFile(), $feature->getLine()); }