Completed
Push — master ( 679529...faf631 )
by Christophe
8s
created

ArrayKeywordsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeywords() 0 4 1
A getKeywordsArray() 0 19 1
A getSteps() 0 13 3
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