/** * Loads feature from provided feature hash. * * @param array $hash Feature hash * @param integer $line Feature definition line * * @return FeatureNode */ protected function loadFeatureHash(array $hash, $line = 0) { $feature = new Node\FeatureNode(null, null, null, isset($hash['line']) ? $hash['line'] : $line); $feature->setKeyword(isset($hash['keyword']) ? $hash['keyword'] : 'Feature'); if (isset($hash['title'])) { $feature->setTitle($hash['title']); } if (isset($hash['description'])) { $feature->setDescription($hash['description']); } if (isset($hash['tags'])) { $feature->setTags($hash['tags']); } if (isset($hash['language'])) { $feature->setLanguage($hash['language']); } if (isset($hash['background'])) { $feature->setBackground($this->loadBackgroundHash($hash['background'])); } if (isset($hash['scenarios'])) { foreach ($hash['scenarios'] as $scenarioIterator => $scenarioHash) { if (isset($scenarioHash['type']) && 'outline' === $scenarioHash['type']) { $feature->addScenario($this->loadOutlineHash($scenarioHash, $scenarioIterator)); } else { $feature->addScenario($this->loadScenarioHash($scenarioHash, $scenarioIterator)); } } } return $feature; }
public function testTags() { $feature = new FeatureNode(); $this->assertFalse($feature->hasTags()); $this->assertInternalType('array', $feature->getTags()); $this->assertEquals(0, count($feature->getTags())); $feature->setTags($tags = array('tag1', 'tag2')); $this->assertEquals($tags, $feature->getTags()); $feature->addTag('tag3'); $this->assertEquals(array('tag1', 'tag2', 'tag3'), $feature->getTags()); $this->assertFalse($feature->hasTag('tag4')); $this->assertTrue($feature->hasTag('tag2')); $this->assertTrue($feature->hasTag('tag3')); }
public function testIsScenarioMatchFilter() { $feature = new Node\FeatureNode(); $scenario = new Node\ScenarioNode(); $feature->addScenario($scenario); $filter = new TagFilter('@wip'); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('wip'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('~@done'); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->addTag('done'); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->setTags(array('tag1', 'tag2', 'tag3')); $filter = new TagFilter('@tag5,@tag4,@tag6'); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('tag5'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('@wip&&@vip'); $feature->setTags(array('wip', 'not-done')); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('vip'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('@wip,@vip&&@user'); $feature->setTags(array('wip')); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->setTags(array('vip')); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->setTags(array('wip', 'user')); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->setTags(array('vip', 'user')); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->setTags(array()); $filter = new TagFilter('@wip'); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('wip'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('~@done'); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->addTag('done'); $this->assertFalse($filter->isScenarioMatch($scenario)); $scenario->setTags(array('tag1', 'tag2', 'tag3')); $filter = new TagFilter('@tag5,@tag4,@tag6'); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('tag5'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('@wip&&@vip'); $scenario->setTags(array('wip', 'not-done')); $this->assertFalse($filter->isScenarioMatch($scenario)); $feature->addTag('vip'); $this->assertTrue($filter->isScenarioMatch($scenario)); $filter = new TagFilter('@wip,@vip&&@user'); $scenario->setTags(array('wip')); $this->assertFalse($filter->isScenarioMatch($scenario)); $scenario->setTags(array('vip')); $this->assertFalse($filter->isScenarioMatch($scenario)); $scenario->setTags(array('wip', 'user')); $this->assertTrue($filter->isScenarioMatch($scenario)); $scenario->setTags(array('vip', 'user')); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->setTags(array('wip')); $scenario->setTags(array('user')); $this->assertTrue($filter->isScenarioMatch($scenario)); $feature->setTags(array()); $this->assertFalse($filter->isScenarioMatch($scenario)); $filter = new TagFilter('@wip,@vip&&~@group'); $feature->setTags(array('vip')); $this->assertTrue($filter->isScenarioMatch($scenario)); $scenario->addTag('group'); $this->assertFalse($filter->isScenarioMatch($scenario)); }
public function setTags(array $tags) { return $this->featureNode->setTags($tags); }