Skip to content

Commit

Permalink
fixed DummyFeatureNode and StepRunner to work with multiple steps
Browse files Browse the repository at this point in the history
  • Loading branch information
mkusher committed Nov 10, 2015
1 parent afe3f71 commit 6a4120f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
28 changes: 14 additions & 14 deletions src/Generator/Node/DummyFeatureNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class DummyFeatureNode
private $featureNode;

/**
* @var StepNode
* @var StepNode[]
*/
private $stepNode;
private $stepNodes;

/**
* @param FeatureNode $featureNode
*/
public function __construct(FeatureNode $featureNode)
{
$this->featureNode = $featureNode;
$this->findStepNode();
$this->findStepNodes();
}

/**
Expand All @@ -36,28 +36,28 @@ public function getFeatureNode()
}

/**
* @return StepNode
* @return StepNode[]
*/
public function getStepNode()
public function getStepNodes()
{
return $this->stepNode;
return $this->stepNodes;
}
private function findStepNode()

private function findStepNodes()
{
$scenarios = $this->featureNode->getScenarios();
if (count($scenarios) === 0) {
throw new \InvalidArgumentException('Unable to find any scenarios in dummy feature');
}

$scenario = $scenarios[0];
$steps = $scenario->getSteps();

if (count($steps) === 0) {
throw new \InvalidArgumentException('Unable to find any steps in dummy feature');
}
$this->stepNode = $steps[0];

$this->stepNodes = $steps;
}
}

}
10 changes: 5 additions & 5 deletions src/Runner/StepRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function run($steps, Suite $suite)
$env = $this->environmentManager->isolateEnvironment($env);

$dummyFeatureNode = $this->generator->generate($steps);

$featureNode = $dummyFeatureNode->getFeatureNode();
$stepNode = $dummyFeatureNode->getStepNode();

$this->stepTester->setUp($env, $featureNode, $stepNode, false);
$result = $this->stepTester->test($env, $featureNode, $stepNode, false);
$this->stepTester->tearDown($env, $featureNode, $stepNode, false, $result);
foreach ($dummyFeatureNode->getStepNodes() as $stepNode) {
$this->stepTester->setUp($env, $featureNode, $stepNode, false);
$result = $this->stepTester->test($env, $featureNode, $stepNode, false);
$this->stepTester->tearDown($env, $featureNode, $stepNode, false, $result);
}

return $result;
}
Expand Down

0 comments on commit 6a4120f

Please sign in to comment.