public function testTags() { $scenario = new ScenarioNode(); $this->assertFalse($scenario->hasTags()); $this->assertInternalType('array', $scenario->getTags()); $this->assertEquals(0, count($scenario->getTags())); $scenario->setTags($tags = array('tag1', 'tag2')); $this->assertEquals($tags, $scenario->getTags()); $scenario->addTag('tag3'); $this->assertEquals(array('tag1', 'tag2', 'tag3'), $scenario->getTags()); $this->assertFalse($scenario->hasTag('tag4')); $this->assertTrue($scenario->hasTag('tag2')); $this->assertTrue($scenario->hasTag('tag3')); }
public function preload() { $this->getMetadata()->setGroups($this->featureNode->getTags()); $this->getMetadata()->setGroups($this->scenarioNode->getTags()); $this->scenario->setMetaStep(null); if ($background = $this->featureNode->getBackground()) { foreach ($background->getSteps() as $step) { $this->validateStep($step); } } foreach ($this->scenarioNode->getSteps() as $step) { $this->validateStep($step); } }
/** * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrine * @param \Doctrine\Common\Persistence\ObjectManager $manager * @param \Behat\Behat\Hook\Scope\ScenarioScope $event * @param \Behat\Gherkin\Node\FeatureNode $feature * @param \Behat\Gherkin\Node\ScenarioNode $scenario * @param \Knp\FriendlyContexts\Alice\Loader\Yaml $loader * @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $userMetadata * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $placeMetadata * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $productMetadata */ function let($container, $doctrine, $manager, $event, $loader, $feature, $scenario, $metadataFactory, $userMetadata, $placeMetadata, $productMetadata) { $doctrine->getManager()->willReturn($manager); $feature->getTags()->willReturn(['alice(Place)', 'admin']); $scenario->getTags()->willReturn(['alice(User)']); $event->getFeature()->willReturn($feature); $event->getScenario()->willReturn($scenario); $loader->load('user.yml')->willReturn([]); $loader->load('product.yml')->willReturn([]); $loader->load('place.yml')->willReturn([]); $loader->getCache()->willReturn([]); $loader->clearCache()->willReturn(null); $fixtures = ['User' => 'user.yml', 'Product' => 'product.yml', 'Place' => 'place.yml']; $config = ['alice' => ['fixtures' => $fixtures, 'dependencies' => []]]; $container->has(Argument::any())->willReturn(true); $container->hasParameter(Argument::any())->willReturn(true); $container->get('friendly.alice.loader.yaml')->willReturn($loader); $container->get('doctrine')->willReturn($doctrine); $container->getParameter('friendly.alice.fixtures')->willReturn($fixtures); $container->getParameter('friendly.alice.dependencies')->willReturn([]); $manager->getMetadataFactory()->willReturn($metadataFactory); $metadataFactory->getAllMetadata()->willReturn([$userMetadata, $placeMetadata, $productMetadata]); $userMetadata->getName()->willReturn('User'); $placeMetadata->getName()->willReturn('Place'); $productMetadata->getName()->willReturn('Product'); $this->initialize($config, $container); }
public function preload() { $this->getMetadata()->setGroups($this->featureNode->getTags()); $this->getMetadata()->setGroups($this->scenarioNode->getTags()); $this->scenario->setMetaStep(null); if ($background = $this->featureNode->getBackground()) { foreach ($background->getSteps() as $step) { $this->validateStep($step); } } foreach ($this->scenarioNode->getSteps() as $step) { $this->validateStep($step); } if ($this->getMetadata()->getIncomplete()) { $this->getMetadata()->setIncomplete($this->getMetadata()->getIncomplete() . "\nRun gherkin:snippets to define missing steps"); } }
public function call($suffix = null) { $this->calls++; $scenario = $this->scenario; if (isset($suffix)) { $scenario = new ScenarioNode($scenario->getTitle() . $suffix, $scenario->getTags(), $scenario->getSteps(), $scenario->getKeyword(), $scenario->getLine()); } $feature = $this->feature; $skip = $this->skip; $isolatedEnvironment = $this->env; $tester = $scenario instanceof OutlineNode ? $this->outlineTester : $this->scenarioTester; $setup = $tester->setUp($isolatedEnvironment, $feature, $scenario, $skip); $localSkip = !$setup->isSuccessful() || $skip; $testResult = $tester->test($isolatedEnvironment, $feature, $scenario, $localSkip); $teardown = $tester->tearDown($isolatedEnvironment, $feature, $scenario, $localSkip, $testResult); $integerResult = new IntegerTestResult($testResult->getResultCode()); $result = new TestWithSetupResult($setup, $integerResult, $teardown); $this->results[] = $result; }
/** * Dumps scenario. * * @param ScenarioNode $scenario Scenario instance * * @return string */ public function dumpScenario(ScenarioNode $scenario) { $keyWordToUse = $scenario instanceof OutlineNode ? $this->keywords->getOutlineKeywords() : $this->keywords->getScenarioKeywords(); $content = '' . (sizeof($scenario->getTags()) > 0 ? PHP_EOL . $this->dumpTags($scenario->getTags(), 1) : '') . PHP_EOL . $this->dumpKeyword($keyWordToUse, $scenario->getTitle(), 1); foreach ($scenario->getSteps() as $step) { $content .= PHP_EOL . $this->dumpIndent(2) . $this->dumpStep($step); } if ($scenario instanceof OutlineNode) { $content .= '' . PHP_EOL . PHP_EOL . $this->dumpKeyword($this->keywords->getExamplesKeywords(), '', 1); $examples = $scenario->getExamples(); $content .= $this->dumpTableNode($examples, 2); } return $content; }