public function testSteps() { $background = new BackgroundNode(); $this->assertEquals(0, count($background->getSteps())); $this->assertFalse($background->hasSteps()); $background->addStep(new StepNode('Given', 'Something')); $this->assertEquals(1, count($background->getSteps())); $this->assertTrue($background->hasSteps()); $background->addStep(new StepNode('Then', 'Do')); $this->assertEquals(2, count($background->getSteps())); $this->assertTrue($background->hasSteps()); $steps = $background->getSteps(); $this->assertInstanceOf('Behat\\Gherkin\\Node\\StepNode', $steps[0]); $this->assertEquals('Given', $steps[0]->getType()); $this->assertEquals('Something', $steps[0]->getText()); $this->assertSame($background, $steps[0]->getParent()); $this->assertEquals('Then', $steps[1]->getType()); $this->assertEquals('Do', $steps[1]->getText()); $this->assertSame($background, $steps[1]->getParent()); }
/** * Loads background from provided hash. * * @param array $hash Background hash * * @return BackgroundNode */ protected function loadBackgroundHash(array $hash) { $background = new Node\BackgroundNode(null, isset($hash['line']) ? $hash['line'] : 0); $background->setKeyword(isset($hash['keyword']) ? $hash['keyword'] : 'Background'); if (isset($hash['title'])) { $background->setTitle($hash['title']); } if (isset($hash['steps'])) { foreach ($hash['steps'] as $stepIterator => $stepHash) { $background->addStep($this->loadStepHash($stepHash, $stepIterator)); } } return $background; }
public function testDumpBackgroundReturnsWellFormatedContent() { $dumper = new Dumper($this->keywords); $background = new BackgroundNode('my title'); $background->addStep(new StepNode('Given', 'I use behat')); $expected = 'Background: my title Given I use behat'; $this->assertEquals($expected, $dumper->dumpBackground($background)); }