public function testExamples()
 {
     $outline = new OutlineNode();
     $this->assertNull($outline->getExamples());
     $this->assertFalse($outline->hasExamples());
     $outline->setExamples($table = new TableNode());
     $this->assertSame($table, $outline->getExamples());
     $this->assertTrue($outline->hasExamples());
 }
Exemplo n.º 2
0
 public function testCreatesEmptyExamplesForNoExampleTable()
 {
     $steps = array(new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'), new StepNode('Aye!', 'my email is <email>', array(), null, 'And'), new StepNode('Blimey!', 'I open homepage', array(), null, 'When'), new StepNode('Let go and haul', 'website should recognise me', array(), null, 'Then'));
     $table = new ExampleTableNode(array(), 'Examples');
     $outline = new OutlineNode(null, array(), $steps, $table, null, null);
     $this->assertCount(0, $examples = $outline->getExamples());
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function printExampleRow(Formatter $formatter, OutlineNode $outline, ExampleNode $example, array $events)
 {
     $rowNum = array_search($example, $outline->getExamples()) + 1;
     $wrapper = $this->getWrapperClosure($outline, $example, $events);
     $row = $outline->getExampleTable()->getRowAsStringWithWrappedValues($rowNum, $wrapper);
     $formatter->getOutputPrinter()->writeln(sprintf('%s%s', $this->indentText, $row));
     $this->printStepExceptionsAndStdOut($formatter->getOutputPrinter(), $events);
 }
Exemplo n.º 4
0
 public function testExamplesIncludesTheOutlineNode()
 {
     $steps = array($step1 = new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'), $step2 = new StepNode('Aye!', 'my email is <email>', array(), null, 'And'), $step3 = new StepNode('Blimey!', 'I open homepage', array(), null, 'When'), $step4 = new StepNode('Let go and haul', 'website should recognise me', array(), null, 'Then'));
     $table = new ExampleTableNode(array(array('name', 'email'), array('user1', '*****@*****.**'), array('user2', '*****@*****.**')), 'Examples');
     $outline = new OutlineNode('outline test title', array(), $steps, $table, null, null);
     $examples = $outline->getExamples();
     for ($i = 0; $i < count($examples); $i++) {
         $this->assertTrue($examples[$i]->getOutline() instanceof OutlineNode);
         $this->assertEquals('outline test title', $examples[$i]->getOutline()->getTitle());
     }
 }
Exemplo n.º 5
0
 public function testCreateExampleStepsWithArguments()
 {
     $steps = array($step1 = new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'), $step2 = new StepNode('Aye!', 'my email is <email>', array(), null, 'And'), $step3 = new StepNode('Blimey!', 'I open:', array(new PyStringNode(array('page: <url>'), null)), null, 'When'), $step4 = new StepNode('Let go and haul', 'website should recognise me', array(new TableNode(array(array('page', '<url>')))), null, 'Then'));
     $table = new ExampleTableNode(array(array('name', 'email', 'url'), array('everzet', '*****@*****.**', 'homepage'), array('example', '*****@*****.**', 'other page')), 'Examples');
     $outline = new OutlineNode(null, array(), $steps, $table, null, null);
     $examples = $outline->getExamples();
     $steps = $examples[0]->getSteps();
     $args = $steps[2]->getArguments();
     $this->assertEquals('page: homepage', $args[0]->getRaw());
     $args = $steps[3]->getArguments();
     $this->assertEquals('| page | homepage |', $args[0]->getTableAsString());
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function test(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip = false)
 {
     $results = array();
     foreach ($outline->getExamples() as $example) {
         $setup = $this->scenarioTester->setUp($env, $feature, $example, $skip);
         $localSkip = !$setup->isSuccessful() || $skip;
         $testResult = $this->scenarioTester->test($env, $feature, $example, $localSkip);
         $teardown = $this->scenarioTester->tearDown($env, $feature, $example, $localSkip, $testResult);
         $integerResult = new IntegerTestResult($testResult->getResultCode());
         $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
     }
     return new TestResults($results);
 }