Skip to content

Commit

Permalink
Fix the OutlineNode object for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dpakach authored and phil-davis committed Nov 12, 2020
1 parent 19c972b commit 55ee35c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Behat/Gherkin/Filter/TagFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct($filterString)
{
$this->filterString = trim($filterString);
}

/**
* Filters feature according to the filter.
*
Expand Down
14 changes: 8 additions & 6 deletions src/Behat/Gherkin/Node/OutlineNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OutlineNode implements ScenarioInterface
*/
private $steps;
/**
* @var ExampleTableNode[]
* @var ExampleTableNode|ExampleTableNode[]
*/
private $tables;
/**
Expand All @@ -52,24 +52,28 @@ class OutlineNode implements ScenarioInterface
* @param null|string $title
* @param string[] $tags
* @param StepNode[] $steps
* @param ExampleTableNode[] $tables
* @param ExampleTableNode|ExampleTableNode[] $tables
* @param string $keyword
* @param integer $line
*/
public function __construct(
$title,
array $tags,
array $steps,
array $tables,
$tables,
$keyword,
$line
) {
$this->title = $title;
$this->tags = $tags;
$this->steps = $steps;
$this->tables = $tables;
$this->keyword = $keyword;
$this->line = $line;
if (!is_array($tables)) {
$this->tables = array($tables);
} else {
$this->tables = $tables;
}
}

/**
Expand Down Expand Up @@ -165,7 +169,6 @@ public function hasExamples()
public function getExampleTable()
{
$table = array();

foreach ($this->tables[0]->getTable() as $k => $v) {
$table[$k] = $v;
}
Expand All @@ -175,7 +178,6 @@ public function getExampleTable()
for ($i = 1; $i < count($this->tables); $i++) {
$exampleTableNode->mergeRowsFromTable($this->tables[$i]);
}

return $exampleTableNode;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Gherkin/Filter/LineFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testIsScenarioMatchFilter()
$filter = new LineFilter(5);
$this->assertFalse($filter->isScenarioMatch($scenario));

$outline = new OutlineNode(null, array(), array(), array(new ExampleTableNode(array(), null)), null, 20);
$outline = new OutlineNode(null, array(), array(), new ExampleTableNode(array(), null), null, 20);

$filter = new LineFilter(5);
$this->assertFalse($filter->isScenarioMatch($outline));
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Gherkin/Keywords/KeywordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function translationTestDataProvider()
), $keywords[0]);
$line += 1;

$scenarios[] = new OutlineNode('Erasing other agents\' memory', array(), $steps, array($table), $outlineKeyword, $outlineLine);
$scenarios[] = new OutlineNode('Erasing other agents\' memory', array(), $steps, $table, $outlineKeyword, $outlineLine);
$line += 1;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Behat/Gherkin/Node/ExampleNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testCreateExampleSteps()
array('example', 'example@example.com')
), 'Examples');

$outline = new OutlineNode(null, array(), $steps, array($table), null, null);
$outline = new OutlineNode(null, array(), $steps, $table, null, null);
$examples = $outline->getExamples();

$this->assertCount(4, $steps = $examples[0]->getSteps());
Expand Down Expand Up @@ -79,7 +79,7 @@ public function testCreateExampleStepsWithArguments()
array('example', 'example@example.com', 'other page')
), 'Examples');

$outline = new OutlineNode(null, array(), $steps, array($table), null, null);
$outline = new OutlineNode(null, array(), $steps, $table, null, null);
$examples = $outline->getExamples();

$steps = $examples[0]->getSteps();
Expand Down
4 changes: 2 additions & 2 deletions tests/Behat/Gherkin/Node/OutlineNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testCreatesExamplesForExampleTable()
23 => array('example', 'example@example.com')
), 'Examples');

$outline = new OutlineNode(null, array(), $steps, array($table), null, null);
$outline = new OutlineNode(null, array(), $steps, $table, null, null);

$this->assertCount(2, $examples = $outline->getExamples());
$this->assertEquals(22, $examples[0]->getLine());
Expand Down Expand Up @@ -92,7 +92,7 @@ public function testCreatesEmptyExamplesForEmptyExampleTable()
array('name', 'email')
), 'Examples');

$outline = new OutlineNode(null, array(), $steps, array($table), null, null);
$outline = new OutlineNode(null, array(), $steps, $table, null, null);

$this->assertCount(0, $examples = $outline->getExamples());
}
Expand Down

0 comments on commit 55ee35c

Please sign in to comment.