OutlineNodeTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Tests\Behat\Gherkin\Node;
  3. use Behat\Gherkin\Node\ExampleTableNode;
  4. use Behat\Gherkin\Node\OutlineNode;
  5. use Behat\Gherkin\Node\StepNode;
  6. class OutlineNodeTest extends \PHPUnit_Framework_TestCase
  7. {
  8. public function testCreatesExamplesForExampleTable()
  9. {
  10. $steps = array(
  11. new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
  12. new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
  13. new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
  14. new StepNode('Let go and haul', 'website should recognise me', array(), null, 'Then'),
  15. );
  16. $table = new ExampleTableNode(array(
  17. array('name', 'email'),
  18. array('everzet', 'ever.zet@gmail.com'),
  19. array('example', 'example@example.com')
  20. ), 'Examples');
  21. $outline = new OutlineNode(null, array(), $steps, $table, null, null);
  22. $this->assertCount(2, $examples = $outline->getExamples());
  23. $this->assertEquals(1, $examples[0]->getLine());
  24. $this->assertEquals(2, $examples[1]->getLine());
  25. $this->assertEquals(array('name' => 'everzet', 'email' => 'ever.zet@gmail.com'), $examples[0]->getTokens());
  26. $this->assertEquals(array('name' => 'example', 'email' => 'example@example.com'), $examples[1]->getTokens());
  27. }
  28. public function testCreatesEmptyExamplesForEmptyExampleTable()
  29. {
  30. $steps = array(
  31. new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
  32. new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
  33. new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
  34. new StepNode('Let go and haul', 'website should recognise me', array(), null, 'Then'),
  35. );
  36. $table = new ExampleTableNode(array(
  37. array('name', 'email')
  38. ), 'Examples');
  39. $outline = new OutlineNode(null, array(), $steps, $table, null, null);
  40. $this->assertCount(0, $examples = $outline->getExamples());
  41. }
  42. public function testCreatesEmptyExamplesForNoExampleTable()
  43. {
  44. $steps = array(
  45. new StepNode('Gangway!', 'I am <name>', array(), null, 'Given'),
  46. new StepNode('Aye!', 'my email is <email>', array(), null, 'And'),
  47. new StepNode('Blimey!', 'I open homepage', array(), null, 'When'),
  48. new StepNode('Let go and haul', 'website should recognise me', array(), null, 'Then'),
  49. );
  50. $table = new ExampleTableNode(array(), 'Examples');
  51. $outline = new OutlineNode(null, array(), $steps, $table, null, null);
  52. $this->assertCount(0, $examples = $outline->getExamples());
  53. }
  54. }