public function testFeatureRolePrefixedWithAn() { $description = <<<NAR In order to be able to read news in my own language As an american user I need to be able to switch website language to french NAR; $feature = new FeatureNode(null, $description, array(), null, array(), null, null, null, 1); $filter = new RoleFilter('american user'); $this->assertTrue($filter->isFeatureMatch($feature)); $filter = new RoleFilter('american *'); $this->assertTrue($filter->isFeatureMatch($feature)); $filter = new RoleFilter('american'); $this->assertFalse($filter->isFeatureMatch($feature)); $filter = new RoleFilter('user'); $this->assertFalse($filter->isFeatureMatch($feature)); $filter = new RoleFilter('*user'); $this->assertTrue($filter->isFeatureMatch($feature)); $filter = new RoleFilter('American User'); $this->assertTrue($filter->isFeatureMatch($feature)); $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, 1); $filter = new RoleFilter('American User'); $this->assertFalse($filter->isFeatureMatch($feature)); }
public function loadTests($filename) { $featureNode = $this->parser->parse(file_get_contents($filename), $filename); if (!$featureNode) { return; } foreach ($featureNode->getScenarios() as $scenarioNode) { /** @var $scenarioNode ScenarioInterface **/ $steps = $this->steps['default']; // load default context foreach (array_merge($scenarioNode->getTags(), $featureNode->getTags()) as $tag) { // load tag contexts if (isset($this->steps["tag:{$tag}"])) { $steps = array_merge($steps, $this->steps["tag:{$tag}"]); } } $roles = $this->settings['gherkin']['contexts']['role']; // load role contexts foreach ($roles as $role => $context) { $filter = new RoleFilter($role); if ($filter->isFeatureMatch($featureNode)) { $steps = array_merge($steps, $this->steps["role:{$role}"]); break; } } if ($scenarioNode instanceof OutlineNode) { foreach ($scenarioNode->getExamples() as $example) { /** @var $example ExampleNode **/ $params = implode(', ', $example->getTokens()); $exampleNode = new ScenarioNode($scenarioNode->getTitle() . " | {$params}", $scenarioNode->getTags(), $example->getSteps(), $example->getKeyword(), $example->getLine()); $this->tests[] = new GherkinFormat($featureNode, $exampleNode, $steps); } continue; } $this->tests[] = new GherkinFormat($featureNode, $scenarioNode, $steps); } }
public function loadTests($filename) { $featureNode = $this->parser->parse(file_get_contents($filename), $filename); foreach ($featureNode->getScenarios() as $scenarioNode) { /** @var $scenarioNode ScenarioNode **/ $steps = $this->steps['default']; // load default context foreach (array_merge($scenarioNode->getTags(), $featureNode->getTags()) as $tag) { // load tag contexts if (isset($this->steps["tag:{$tag}"])) { $steps = array_merge($steps, $this->steps["tag:{$tag}"]); } } $roles = $this->settings['gherkin']['contexts']['role']; // load role contexts foreach ($roles as $role) { $filter = new RoleFilter($role); if ($filter->isFeatureMatch($featureNode)) { $steps = array_merge($steps, $this->steps["role:{$role}"]); break; } } $this->tests[] = new GherkinFormat($featureNode, $scenarioNode, $steps); } }