Completed
Pull Request — master (#112)
by Christophe
02:50
created

FilterTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 56
c 0
b 0
f 0
wmc 3
lcom 0
cbo 4
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getParser() 0 21 1
B getGherkinFeature() 0 26 1
A getParsedFeature() 0 4 1
1
<?php
2
3
namespace Tests\Behat\Gherkin\Filter;
4
5
use Behat\Gherkin\Keywords\ArrayKeywords;
6
use Behat\Gherkin\Lexer;
7
use Behat\Gherkin\Parser;
8
9
abstract class FilterTest extends \PHPUnit_Framework_TestCase
10
{
11
    protected function getParser()
12
    {
13
        return new Parser(
14
            new Lexer(
15
                new ArrayKeywords(array(
16
                    'en' => array(
17
                        'feature'          => 'Feature',
18
                        'background'       => 'Background',
19
                        'scenario'         => 'Scenario',
20
                        'scenario_outline' => 'Scenario Outline|Scenario Template',
21
                        'examples'         => 'Examples|Scenarios',
22
                        'given'            => 'Given',
23
                        'when'             => 'When',
24
                        'then'             => 'Then',
25
                        'and'              => 'And',
26
                        'but'              => 'But'
27
                    )
28
                ))
29
            )
30
        );
31
    }
32
33
    protected function getGherkinFeature()
34
    {
35
        return <<<GHERKIN
36
Feature: Long feature with outline
37
  Scenario: Scenario#1
38
    Given initial step
39
    When action occurs
40
    Then outcomes should be visible
41
42
  Scenario: Scenario#2
43
    Given initial step
44
    And another initial step
45
    When action occurs
46
    Then outcomes should be visible
47
48
  Scenario Outline: Scenario#3
49
    When <action> occurs
50
    Then <outcome> should be visible
51
52
    Examples:
53
      | action | outcome |
54
      | act#1  | out#1   |
55
      | act#2  | out#2   |
56
      | act#3  | out#3   |
57
GHERKIN;
58
    }
59
60
    protected function getParsedFeature()
61
    {
62
        return $this->getParser()->parse($this->getGherkinFeature());
63
    }
64
}
65