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

OutlineNodeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreatesExamplesForExampleTable() 0 23 1
A testCreatesEmptyExamplesForEmptyExampleTable() 0 17 1
A testCreatesEmptyExamplesForNoExampleTable() 0 15 1
1
<?php
2
3
namespace Tests\Behat\Gherkin\Node;
4
5
use Behat\Gherkin\Node\ExampleTableNode;
6
use Behat\Gherkin\Node\OutlineNode;
7
use Behat\Gherkin\Node\StepNode;
8
9
class OutlineNodeTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testCreatesExamplesForExampleTable()
12
    {
13
        $steps = array(
14
            new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
15
            new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
16
            new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
17
            new StepNode('Let go and haul',  'website should recognise me', array(), null, 'Then'),
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
18
        );
19
20
        $table = new ExampleTableNode(array(
21
            array('name', 'email'),
22
            array('everzet', '[email protected]'),
23
            array('example', '[email protected]')
24
        ), 'Examples');
25
26
        $outline = new OutlineNode(null, array(), $steps, $table, null, null);
27
28
        $this->assertCount(2, $examples = $outline->getExamples());
29
        $this->assertEquals(1, $examples[0]->getLine());
30
        $this->assertEquals(2, $examples[1]->getLine());
31
        $this->assertEquals(array('name' => 'everzet', 'email' => '[email protected]'), $examples[0]->getTokens());
32
        $this->assertEquals(array('name'  => 'example', 'email' => '[email protected]'), $examples[1]->getTokens());
33
    }
34
35
    public function testCreatesEmptyExamplesForEmptyExampleTable()
36
    {
37
        $steps = array(
38
            new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
39
            new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
40
            new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
41
            new StepNode('Let go and haul',  'website should recognise me', array(), null, 'Then'),
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
42
        );
43
44
        $table = new ExampleTableNode(array(
45
            array('name', 'email')
46
        ), 'Examples');
47
48
        $outline = new OutlineNode(null, array(), $steps, $table, null, null);
49
50
        $this->assertCount(0, $examples = $outline->getExamples());
51
    }
52
53
    public function testCreatesEmptyExamplesForNoExampleTable()
54
    {
55
        $steps = array(
56
            new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
57
            new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
58
            new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
59
            new StepNode('Let go and haul',  'website should recognise me', array(), null, 'Then'),
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
60
        );
61
62
        $table = new ExampleTableNode(array(), 'Examples');
63
64
        $outline = new OutlineNode(null, array(), $steps, $table, null, null);
65
66
        $this->assertCount(0, $examples = $outline->getExamples());
67
    }
68
}
69