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'), |
|
|
|
|
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'), |
|
|
|
|
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'), |
|
|
|
|
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
|
|
|
|