22
33namespace Tests \Behat \Gherkin \Node ;
44
5+ use Behat \Gherkin \Node \ExampleNode ;
56use Behat \Gherkin \Node \ExampleTableNode ;
67use Behat \Gherkin \Node \OutlineNode ;
78use Behat \Gherkin \Node \StepNode ;
89use PHPUnit \Framework \TestCase ;
910
1011class OutlineNodeTest extends TestCase
1112{
12- public function testCreatesExamplesForExampleTable ()
13+ public function testCreatesExamplesForExampleTable (): void
1314 {
1415 $ steps = array (
1516 new StepNode ('Gangway! ' , 'I am <name> ' , array (), null , 'Given ' ),
@@ -33,7 +34,7 @@ public function testCreatesExamplesForExampleTable()
3334 $ this ->assertEquals (array ('name ' => 'example ' , 'email ' => 'example@example.com ' ), $ examples [1 ]->getTokens ());
3435 }
3536
36- public function testCreatesExamplesForExampleTableWithSeveralExamplesAndTags ()
37+ public function testCreatesExamplesForExampleTableWithSeveralExamplesAndTags (): void
3738 {
3839 $ steps = array (
3940 new StepNode ('Gangway! ' , 'I am <name> ' , array (), null , 'Given ' ),
@@ -79,7 +80,7 @@ public function testCreatesExamplesForExampleTableWithSeveralExamplesAndTags()
7980 }
8081 }
8182
82- public function testCreatesEmptyExamplesForEmptyExampleTable ()
83+ public function testCreatesEmptyExamplesForEmptyExampleTable (): void
8384 {
8485 $ steps = array (
8586 new StepNode ('Gangway! ' , 'I am <name> ' , array (), null , 'Given ' ),
@@ -94,10 +95,10 @@ public function testCreatesEmptyExamplesForEmptyExampleTable()
9495
9596 $ outline = new OutlineNode (null , array (), $ steps , $ table , null , null );
9697
97- $ this ->assertCount (0 , $ examples = $ outline ->getExamples ());
98+ $ this ->assertCount (0 , $ outline ->getExamples ());
9899 }
99100
100- public function testCreatesEmptyExamplesForNoExampleTable ()
101+ public function testCreatesEmptyExamplesForNoExampleTable (): void
101102 {
102103 $ steps = array (
103104 new StepNode ('Gangway! ' , 'I am <name> ' , array (), null , 'Given ' ),
@@ -110,10 +111,10 @@ public function testCreatesEmptyExamplesForNoExampleTable()
110111
111112 $ outline = new OutlineNode (null , array (), $ steps , array ($ table ), null , null );
112113
113- $ this ->assertCount (0 , $ examples = $ outline ->getExamples ());
114+ $ this ->assertCount (0 , $ outline ->getExamples ());
114115 }
115116
116- public function testPopulatesExampleWithOutlineTitle ()
117+ public function testPopulatesExampleWithOutlineTitle (): void
117118 {
118119 $ steps = array (
119120 new StepNode ('' , 'I am <name> ' , array (), null , 'Given ' ),
@@ -122,11 +123,37 @@ public function testPopulatesExampleWithOutlineTitle()
122123 $ table = new ExampleTableNode (array (
123124 10 => array ('name ' , 'email ' ),
124125 11 => array ('Ciaran ' , 'ciaran@example.com ' ),
126+ 12 => array ('John ' , 'john@example.com ' ),
125127 ), 'Examples ' );
126128
127- $ outline = new OutlineNode ('An outline title ' , array (), $ steps , $ table , null , null );
128-
129- $ this ->assertCount (1 , $ examples = $ outline ->getExamples ());
130- $ this ->assertEquals ('An outline title ' , current ($ examples )->getOutlineTitle ());
129+ $ outline = new OutlineNode ('An outline title for <name> ' , array (), $ steps , $ table , null , null );
130+
131+ $ this ->assertSame (
132+ [
133+ [
134+ 'getName ' => 'An outline title for Ciaran #1 ' ,
135+ 'getTitle ' => '| Ciaran | ciaran@example.com | ' ,
136+ 'getOutlineTitle ' => 'An outline title for <name> ' ,
137+ 'getExampleText ' => '| Ciaran | ciaran@example.com | ' ,
138+ ],
139+ [
140+ 'getName ' => 'An outline title for John #2 ' ,
141+ 'getTitle ' => '| John | john@example.com | ' ,
142+ 'getOutlineTitle ' => 'An outline title for <name> ' ,
143+ 'getExampleText ' => '| John | john@example.com | ' ,
144+ ],
145+ ],
146+ array_map (
147+ static function (ExampleNode $ node ) {
148+ return [
149+ 'getName ' => $ node ->getName (),
150+ 'getTitle ' => $ node ->getTitle (),
151+ 'getOutlineTitle ' => $ node ->getOutlineTitle (),
152+ 'getExampleText ' => $ node ->getExampleText (),
153+ ];
154+ },
155+ $ outline ->getExamples ()
156+ )
157+ );
131158 }
132159}
0 commit comments