@param  FeatureNode  $featureNode
@param  ScenarioInterface $scenarioNode

@return string
5926
public function generateFileName(FeatureNode $featureNode, ScenarioInterface $scenarioNode)
    {
        $feature = $this->relativizePaths($featureNode->getFile());
        $line = $scenarioNode->getLine();
        $fileName = join('_', [$feature, $line]);
        return preg_replace('/[^A-Za-z0-9\-]/', '_', mb_strtolower($fileName)) . '.png';
    }
208608
public function searchDefinition(
        Environment $environment,
        FeatureNode $feature,
        StepNode $step
    ) {
        $suite = $environment->getSuite();
        $language = $feature->getLanguage();
        $stepText = $step->getText();
        $multi = $step->getArguments();

        $definitions = array();
        $result = null;

        foreach ($this->repository->getEnvironmentDefinitions($environment) as $definition) {
            $definition = $this->translator->translateDefinition($suite, $definition, $language);

            if (!$newResult = $this->match($definition, $stepText, $multi)) {
                continue;
            }

            $result = $newResult;
            $definitions[] = $newResult->getMatchedDefinition();
        }

        if (count($definitions) > 1) {
            throw new AmbiguousMatchException($result->getMatchedText(), $definitions);
        }

        return $result;
    }
1207545
public function resolveName(NodeInterface $parentNode, $name, NodeInterface $forNode = null, $autoRename = true)
    {
        $index = 0;
        $baseName = $name;

        if ($this->hasNameConflict($parentNode, $name, $forNode) && !$autoRename) {
            throw new NodeNameAlreadyExistsException($name);
        }

        while ($this->hasNameConflict($parentNode, $name, $forNode)) {
            $name = $baseName . '-' . ++$index;
        }

        return $name;
    }
158481
private function _getScenarios($featurePath)
    {
        $scenarios = [];
        /* @var $featureNodes \Behat\Gherkin\Node\FeatureNode[] */
        $featureNodes = $this->container->get('gherkin')->load($featurePath);
        foreach ($featureNodes as $featureNode) {
            /* @var $scenario \Behat\Gherkin\Node\ScenarioNode */
            foreach ($featureNode->getScenarios() as $scenario) {
                $file = $scenario->getFile();
                $lines = [$scenario->getLine()];

                if ($scenario instanceof OutlineNode) {
                    $lines = $scenario->getExamples()->getRowLines();
                    array_shift($lines);
                }

                foreach ($lines as $line) {
                    $scenarios[] = "$file:$line";
                }
            }
        }

        return $scenarios;
    }
492120
public function getFeature($featureName, $permissive = false) {
        $feature = Feature::findByName($this->features, $featureName, $permissive);
        if (!$feature)
            throw new ModelException("the model has no feature named \"$featureName\"");
        return $feature;
    }
1018694
public function isScenarioMatch(ScenarioInterface $scenario)
    {
        if ($this->filterMinLine <= $scenario->getLine() && $this->filterMaxLine >= $scenario->getLine()) {
            return true;
        }

        if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
            foreach ($scenario->getExampleTable()->getLines() as $line) {
                if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) {
                    return true;
                }
            }
        }

        return false;
    }
1054991
private function getSteps(ScenarioInterface $scenario)
    {
        if (! $scenario->hasSteps()) {
            return;
        }

        $step = new Step($this->align);

        return $step->format($scenario->getSteps()) . "\n";
    }
1301755
public function bind($eventName, $scenarioClassName)
    {
        if (!is_callable($scenarioClassName)) {
            $this->assertScenarioExists($scenarioClassName);
            $this->assertScenarioIsRunnable($scenarioClassName);
        }

        // todo solve multiple event bindings problem
        // actual solution is to rebind, latest binding wins

        $this->registeredScenarios[$eventName] = $scenarioClassName;
    }
604453
public function toQuery( $variableSet, $factVariableBinding )
	{
		/**
		 * These are the arguments to the xfi:concept-relationships function
	     * #source
		 * #linkrole
		 * #arcrole
		 * #axis
		 * #generations
		 * #linkname
		 * #arcname
		 */

		$source = $this->variable
					? ( "fn:node-name(" . ( $this->variable['originalPrefix'] ? "\${$this->variable['originalPrefix']}:$this->variable['name']" : "\${$this->variable['name']}" ) . ")" )
					: ( $this->qnameExpression
							? $this->qnameExpression
							: "QName('" . qname($this->qname, $variableSet->nsMgr->getNamespaces())->namespaceURI . "', '" . qname($this->qname, $variableSet->nsMgr->getNamespaces())->localName . "')"
					  );

		$linkrole = $this->linkrole
					? "'{$this->linkrole}'"
					: ( $this->linkroleExpression
							? $this->linkroleExpression
							: "()"
					  );

		$arcrole = $this->arcrole
					? "'{$this->arcrole}'"
					: ( $this->arcroleExpression
							? $this->arcroleExpression
							: "()"
					  );

		$axis = "{$this->axis}";
		$generations = $this->generations ? $this->generations : "()";

		$linkname = $this->linkname
					? "'{$this->linkname}'"
					: ( $this->linknameExpression
							? $this->linknameExpression
							: "()"
					  );

		$arcname = $this->arcname
					? "'{$this->arcname}'"
					: ( $this->arcnameExpression
							? $this->arcnameExpression
							: "()"
					  );

		$test = $this->test
					? $this->test
					: "true()";

		// Alternative line end goes here (for query formatting)
		$le = "";

		$query = "( $le" .
				 "	( $le" .
				 "		some \$relationship in $le" .
				 "			xfi:concept-relationships( $le" .
				 "				$source, $le" .
				 "				$linkrole, $le" .
				 "				$arcrole, $le" .
				 "				" . str_replace( "-or-self", "", "'$axis'" ) . ",$le" .
		//		 "				fn:replace($axis,'-or-self',''), $le" .
				 "				$generations, $le" .
				 "				$linkname, $le" .
				 "				$arcname $le" .
				 "			) $le" .
				 "		satisfies $le" .
				 "			( $le" .
				 "				\$relationship[$test] and $le" .
				 "				(fn:node-name(.) eq $le" .
             	 "					( $le" .
             	 "						if (matches('$axis','ancestor|parent')) $le" .
              	 "						then xfi:relationship-from-concept(\$relationship) $le" .
              	 "						else xfi:relationship-to-concept(\$relationship) $le" .
              	 "					) $le" .
              	 "				) $le" .
              	 "			) $le" .
              	 "  ) $le";

		$clause1 = "" .
				 "	or $le" .
				 "	( $le" .
		//		 "		fn:starts-with($axis,'sibling') and $le" .
				 "		fn:empty( $le" .
				 "			xfi:concept-relationships( $source, $linkrole, $arcrole, 'parent', 1, $linkname, $arcname) $le" .
				 "		) and $le" .
				 "		fn:empty( $le" .
				 "			xfi:concept-relationships( fn:node-name(.), $linkrole, $arcrole, 'parent', 1, $linkname, $arcname) $le" .
				 "		) and $le" .
				 "		fn:exists( $le" .
				 "			xfi:concept-relationships( fn:node-name(.), $linkrole, $arcrole, 'child', 1, $linkname, $arcname) $le" .
				 "		) and $le" .
				 "		(fn:node-name(.) ne $source) $le" .
				 "	) $le";

		$clause2 = "" .
				 "	or $le" .
				 "	( $le" .
		//		 "		fn:ends-with($axis,'-or-self') $le" .
		//		 " 		and $le" .
		//		 "		( $le" .
				 "			if ( QName('http://www.xbrl.org/2008/function/instance','root') eq $source) $le" .
				 "			then $le" .
				 "			( $le" .
				 "				fn:empty( $le" .
				 "					xfi:concept-relationships( fn:node-name(.), $linkrole, $arcrole, 'parent', 1, $linkname, $arcname) $le" .
				 "				) and $le" .
				 "				fn:exists( $le" .
				 "					xfi:concept-relationships( fn:node-name(.), $linkrole, $arcrole, 'child', 1, $linkname, $arcname) $le" .
				 "				) $le" .
				 "			) $le" .
				 "			else $le" .
				 "			( $le" .
				 "				fn:node-name(.) eq $source $le" .
				 "			) $le" .
		//		 "		) $le" .
				 "  ) $le";

		$query = $query . ( \XBRL::startsWith( $axis, 'sibling' ) ? $clause1 : "" ) . ( \XBRL::endsWith( $axis, '-or-self' ) ? $clause2 : "" );
		$query .= ") $le";
		if ( empty( $le ) )
		{
			$query = preg_replace( "/\s\t+/", " ", $query );
		}
		echo $query;
		return $query;
	}
823765
private function convertVariableNameToString(Node $variableNode)
    {
        return $variableNode instanceof Node\Expr\Variable && is_string($variableNode->name)
            ? $variableNode->name
            : FunctionLikeScope::VARIABLE_VARIABLE_NAME;
    }
1044439
public function indexAction($featureId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

        if (!$feature) {
            throw $this->createNotFoundException('Unable to find Feature entity.');
        }

        return array(
            'feature'    => $feature,
        );
    }
452799
public function create(FeatureCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $feature = new FeatureModel();

        $feature
            ->setDispatcher($dispatcher)

            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())

            ->save()
        ;

        $event->setFeature($feature);

        // Add atribute to all product templates if required
        if ($event->getAddToAllTemplates() != 0) {
            $this->doAddToAllTemplates($feature);
        }
    }
1152512
public static function fromNode($node, $parent) {
        if (is_null($node["value"]))
            return new Feature($node, $parent, $node->children());
        else
            return new ValueFeature($node, $parent, $node->children());
    }
961073
public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result)
    {
        /** @var JUnitOutputPrinter $outputPrinter */
        $outputPrinter = $formatter->getOutputPrinter();

        $message = $step->getKeyword() . ' ' . $step->getText();

        if ($result instanceof ExceptionResult && $result->hasException()) {
            $message .= ': ' . $this->exceptionPresenter->presentException($result->getException());
        }

        $attributes = array('message' => $message);

        switch ($result->getResultCode()) {
            case TestResult::FAILED:
                $outputPrinter->addTestcaseChild('failure', $attributes);
                break;

            case TestResult::PENDING:
                $attributes['type'] = 'pending';
                $outputPrinter->addTestcaseChild('error', $attributes);
                break;

            case StepResult::UNDEFINED:
                $attributes['type'] = 'undefined';
                $outputPrinter->addTestcaseChild('error', $attributes);
                break;
        }
    }
1035928
public function filterFeature(FeatureNode $feature)
    {
        $scenarios = array();
        foreach ($feature->getScenarios() as $scenario) {
            if (!$this->isScenarioMatch($scenario)) {
                continue;
            }

            if ($scenario instanceof OutlineNode && $scenario->hasExamples()) {
                $table = $scenario->getExampleTable()->getTable();
                $lines = array_keys($table);

                $filteredTable = array($lines[0] => $table[$lines[0]]);
                unset($table[$lines[0]]);

                foreach ($table as $line => $row) {
                    if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) {
                        $filteredTable[$line] = $row;
                    }
                }

                $scenario = new OutlineNode(
                    $scenario->getTitle(),
                    $scenario->getTags(),
                    $scenario->getSteps(),
                    new ExampleTableNode($filteredTable, $scenario->getExampleTable()->getKeyword()),
                    $scenario->getKeyword(),
                    $scenario->getLine()
                );
            }

            $scenarios[] = $scenario;
        }

        return new FeatureNode(
            $feature->getTitle(),
            $feature->getDescription(),
            $feature->getTags(),
            $feature->getBackground(),
            $scenarios,
            $feature->getKeyword(),
            $feature->getLanguage(),
            $feature->getFile(),
            $feature->getLine()
        );
    }
303226
private function isMatch(FeatureNode $feature, $filterString)
    {
        if (false !== strpos($filterString, '@')) {
            return $this->isMatchTagFilter($feature, $filterString);
        }

        if (!empty($filterString)) {
            return $this->isMatchNameFilter($feature, $filterString);
        }

        return false;
    }
941948
public function hasNode(NodeInterface $node, $locale)
    {
        return array_key_exists($this->getNodeLocaleKey($node->getIdentifier(), $locale), $this->nodeDocumentMap);
    }