コード例 #1
0
    public function testIsScenarioMatchFilter()
    {
        $feature = new Node\FeatureNode(null, <<<NAR
In order to be able to read news in my own language
As a french user
I need to be able to switch website language to french
NAR
, null, 1);
        $scenario = new Node\ScenarioNode(null, 2);
        $scenario->setFeature($feature);
        $filter = new RoleFilter('french user');
        $this->assertTrue($filter->isScenarioMatch($scenario));
        $filter = new RoleFilter('french *');
        $this->assertTrue($filter->isScenarioMatch($scenario));
        $filter = new RoleFilter('french');
        $this->assertFalse($filter->isScenarioMatch($scenario));
        $filter = new RoleFilter('user');
        $this->assertFalse($filter->isScenarioMatch($scenario));
        $filter = new RoleFilter('*user');
        $this->assertTrue($filter->isScenarioMatch($scenario));
        $filter = new RoleFilter('French User');
        $this->assertTrue($filter->isScenarioMatch($scenario));
    }
コード例 #2
0
ファイル: RoleFilterTest.php プロジェクト: higrow/Gherkin
    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));
    }
コード例 #3
0
ファイル: Gherkin.php プロジェクト: solutionDrive/Codeception
 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);
     }
 }
コード例 #4
0
ファイル: Gherkin.php プロジェクト: neronmoon/Codeception
 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);
     }
 }