Completed
Pull Request — master (#108)
by Christophe
03:03
created

ArrayKeywordsTest::getSteps()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 4
1
<?php
2
3
namespace Tests\Behat\Gherkin\Keywords;
4
5
use Behat\Gherkin\Keywords\ArrayKeywords;
6
use Behat\Gherkin\Node\StepNode;
7
8
class ArrayKeywordsTest extends KeywordsTest
9
{
10
    protected function getKeywords()
11
    {
12
        return new ArrayKeywords($this->getKeywordsArray());
13
    }
14
15
    protected function getKeywordsArray()
16
    {
17
        return array(
18
            'with_special_chars' => array(
19
                'and' => 'And/foo',
20
                'background' => 'Background.',
21
                'but' => 'But[',
22
                'examples' => 'Examples|Scenarios',
23
                'feature' => 'Feature|Business Need|Ability',
24
                'given' => 'Given',
25
                'name' => 'English',
26
                'native' => 'English',
27
                'scenario' => 'Scenario',
28
                'scenario_outline' => 'Scenario Outline|Scenario Template',
29
                'then' => 'Then',
30
                'when' => 'When',
31
            ),
32
        );
33
    }
34
35
    protected function getSteps($keywords, $text, &$line, $keywordType)
36
    {
37
        $steps = array();
38
        foreach (explode('|', $keywords) as $keyword) {
39
            if (false !== mb_strpos($keyword, '<')) {
40
                $keyword = mb_substr($keyword, 0, -1);
41
            }
42
43
            $steps[] = new StepNode($keyword, $text, array(), $line++, $keywordType);
44
        }
45
46
        return $steps;
47
    }
48
}
49